2010-01-22 80 views
1

我想要一个“不空”约束在Oracle中添加一列9为什么这个'修改表'语句失败?

ALTER TABLE user_roles modify group_id varchar2(36 char) set not null; 

但是,操作失败,一个奇怪的错误:

Error report: 
SQL Error: ORA-12987: cannot combine drop column with other operations 
12987. 00000 - "cannot combine drop column with other operations" 
*Cause: An attempt was made to combine drop column with other 
      ALTER TABLE operations. 
*Action: Ensure that drop column is the sole operation specified in 
      ALTER TABLE. 

任何想法,为什么这失败了?

+0

谢谢,OMG小马 - 添加错误代码是一个好主意。 – johnstok 2010-01-22 15:57:18

回答

2

删除set

ALTER TABLE user_roles modify group_id varchar2(36 char) not null 

是的,Oracle的错误可能是很大的误导。

0

I'm trying to add a 'not null' constraint to a column in Oracle 9.

如果你真的想仅仅指刚让列NOT NULL(即你不想改变在同一时间的数据类型),你只需要

ALTER TABLE user_roles modify not null; 
0

原来,上述语句的语法是错误的。它应该是:

ALTER TABLE user_roles modify group_id varchar2(36 char) not null; 

不过,存在一个错误的'set'会导致一个非常奇怪的错误!