Oracle 11g - add new column and set as unique

瘦欲@ 提交于 2019-12-10 20:15:54

问题


I am facing a problem on how to set a new column to unique using Oracle 11g.

I try to use this code but it getting error:

ALTER TABLE QAS_ASSIGNED_STATE ADD UNIQUE (cuid);

回答1:


You should define column's type. Like this:

alter table
    QAS_ASSIGNED_STATE 
 add
    cuid number NULL;

and then add constraint:

ALTER TABLE QAS_ASSIGNED_STATE ADD CONSTRAINT constraint_cuid  UNIQUE (cuid );


来源:https://stackoverflow.com/questions/36030261/oracle-11g-add-new-column-and-set-as-unique

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!