简体   繁体   English

添加列时无效的ALTER TABLE OPTION

[英]INVALID ALTER TABLE OPTION on adding column

I am trying to add a new column to an already existing table. 我正在尝试将新列添加到现有表中。 I am using Oracle 12c. 我正在使用Oracle 12c。 The SQL Code goes like this: SQL代码如下所示:

ALTER TABLE table_name 
ADD column_name VARCHAR(120) 
DEFAULT 'Test' NOT NULL;

I am getting Error Msg = ORA-01735: Invalid ALTER TABLE option . 我收到Error Msg = ORA-01735: Invalid ALTER TABLE option What am i doing wrong? 我究竟做错了什么?

SOLVED, PLEASE DELETE 已解决,请删除

I had a project-specific error while compiling my SQL statement, the problem has been solved and there was nothing wrong with the statement to begin with. 我在编译SQL语句时遇到了特定于项目的错误,该问题已解决,并且从一开始就没有问题。

Your brackets are wrong, it must be 您的括号是错误的,一定是

alter table job_details add (sched_name varchar2(120) DEFAULT 'TestScheduler' not null);

or 要么

alter table job_details add sched_name varchar2(120) DEFAULT 'TestScheduler' not null;

That's rather simple; 那很简单;

SQL> create table table_name (id number);

Table created.

SQL> alter table table_name add
  2    column_name varchar(120)
  3    default 'Test'
  4    not null;

Table altered.

SQL>

Though, saying that "your console outputs ...", what is the console ? 但是,说“您的控制台输出...”时, 控制台是什么? Which tool do you use? 您使用哪个工具?

[EDIT - everything included into the CREATE TABLE statement] [编辑-CREATE TABLE语句中包含的所有内容]

SQL> create table table_name
  2    (id           number,
  3     column_name  varchar2(120) default 'Test' not null
  4    );

Table created.

SQL>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM