[翻译]  Why does Oracle think I'm missing a right parenthesis?

[CHINESE]  为什么Oracle认为我错过了一个正确的括号?


In Oracle 10i, I'm running the following command:

在Oracle 10i中,我运行以下命令:

ALTER TABLE jnrvwchnglst ADD
     ( jnrvwchnglst_userid NUMBER(10) NOT NULL DEFAULT 1 )

Yes jnrvwchnglst is an existing table and no jnrvwchnglst_userid is not an existing column.

是jnrvwchnglst是现有表,并且没有jnrvwchnglst_userid不是现有列。

The Oracle error message is:

Oracle错误消息是:

ORA-00907: missing right parenthesis

What's wrong with this query and why does Oracle think I'm missing a parenthesis?

这个查询出了什么问题,为什么Oracle认为我错过了一个括号?

3 个解决方案

#1


20  

ALTER TABLE jnrvwchnglst ADD
     ( jnrvwchnglst_userid NUMBER(10) DEFAULT 1  NOT NULL )

#2


3  

"(NOT) NULL" must be the last statement in the "ALTER" syntactically when present, so when Oracle saw that - and that the next char (your "DEFAULT" stmt) wasn't the expected terminating right ")", threw the error.

“(NOT)NULL”必须是语法中“ALTER”中的最后一个语句,所以当Oracle看到 - 并且下一个char(你的“DEFAULT”stmt)不是预期的终止权限时“)”,扔了错误。

#3


0  

I have had this issue before where you can't add a column AND set the default/constraints in the same statement. The 'missing right parenthesis' is a red-herring. Oracle loves to use that error for cases that are unrelated to parenthesis (My guess is that their parsing logic falls through to 00907).

在您无法添加列并在同一语句中设置默认/约束之前,我遇到过此问题。 '缺少右括号'是一个红鲱鱼。 Oracle喜欢将这个错误用于与括号无关的情况(我的猜测是它们的解析逻辑落到了00907)。

Try

尝试

ALTER TABLE jnrvwchnglst ADD ( nrvwchnglst_userid NUMBER(10) );
ALTER TABLE jnrvwchnglst ALTER ( nrvwchnglst_userid  SET DEFAULT 1 );
UPDATE jnrvwchnglst SET nrvwchnglst_userid = 1 WHERE nrvwchnglst_userid IS NULL;
ALTER TABLE jnrvwchnglst  ALTER ( nrvwchnglst_userid  SET NOT NULL );

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号