oracle 删除not null非空约束
system@ORCL> create table testnull(id int not null,name varchar2(10) not null);
Table created.
system@ORCL> desc testnull
Name Null? Type
——————————————– ——– ——————————————————–
ID NOT NULL NUMBER(38)
NAME NOT NULL VARCHAR2(10)
system@ORCL> desc DBA_CONS_COLUMNS
Name Null? Type
——————————————– ——– ——————————————————–
OWNER NOT NULL VARCHAR2(30)
CONSTRAINT_NAME NOT NULL VARCHAR2(30)
TABLE_NAME NOT NULL VARCHAR2(30)
COLUMN_NAME VARCHAR2(4000)
POSITION NUMBER
system@ORCL> COL COLUMN_NAME FOR A20
system@ORCL> SELECT CONSTRAINT_NAME,COLUMN_NAME FROM DBA_CONS_COLUMNS WHERE TABLE_NAME=’TESTNULL’
CONSTRAINT_NAME COLUMN_NAME
—————————— ——————–
SYS_C0012465 ID
SYS_C0012466 NAME
system@ORCL> alter table testnull drop constraint SYS_C0012465;
Table altered.
system@ORCL> desc testnull;
Name Null? Type
—————————– ——– ——————————————————–
ID NUMBER(38)
NAME NOT NULL VARCHAR2(10)
system@ORCL> alter table testnull name varchar2(10) null;
alter table testnull name varchar2(10) null
*
ERROR at line 1:
ORA-01735: invalid ALTER TABLE option
system@ORCL> alter table testnull modify name varchar2(10) null;
Table altered.
system@ORCL> desc testnull;
Name Null? Type
——————————— ——– ——————————————————–
ID NUMBER(38)
NAME VARCHAR2(10)
对不起,这篇文章暂时关闭评论。