2010-01-22 74 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'會導致一個非常奇怪的錯誤!