Add notnull constraint to a column of an existing table

无人久伴 提交于 2021-02-11 14:55:36

问题


How to add notnull constraint to a column of an existing table in which no value is yet inserted i.e. only table is created and now i want to alter the table i am writing the following query

       ALTER TABLE TABLENAME MODIFY COLUMNAME DATATYPE NOT NULL;

but oracle is throwing error "invalid alter table option"


回答1:


In an alter table you only have to specify what changes

ALTER TABLE TABLENAME MODIFY COLUMNAME NOT NULL;

As you don't change the datatype, you don't have to specify it again.



来源:https://stackoverflow.com/questions/46516768/add-notnull-constraint-to-a-column-of-an-existing-table

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