Why does this 'modify table' statement fail?
I'm trying to add a 'not null' constraint to a column in Oracle 9.
ALTER TABLE user_roles modify group_id varchar2(36 char) set not null;
However, the operation fails with an odd error:
开发者_高级运维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.
Any ideas why this is failing?
Remove set
:
ALTER TABLE user_roles modify group_id varchar2(36 char) not null
And yes, Oracle
's errors can be very misleading.
It turns out the syntax of the above statement is wrong. It should be:
ALTER TABLE user_roles modify group_id varchar2(36 char) not null;
Still, the presence of an erroneous 'set' leads to a very odd error!
I'm trying to add a 'not null' constraint to a column in Oracle 9.
If you are really trying jsut to make the column NOT NULL (i.e. you don't want to change the datatype at the same time) you just need to
ALTER TABLE user_roles modify not null;
精彩评论