SQL> create table test(a number, b number);
Table created
SQL> desc test;
Name Type Nullable Default Comments
---- ------ -------- ------- --------
A NUMBER Y
B NUMBER Y
SQL> alter table test modify a not null novalidate;
Table altered
SQL> desc test;
Name Type Nullable Default Comments
---- ------ -------- ------- --------
A NUMBER Y
B NUMBER Y
SQL> insert into test(b) values(1);
insert into test(b) values(1)
ORA-01400: 无法将 NULL 插入 ("xx"."TEST"."A")
SQL> select c.constraint_name,c.constraint_type,cc.column_name from user_constraints c, user_cons_columns cc
2 where c.table_name='TEST' and c.constraint_name=cc.constraint_name;
CONSTRAINT_NAME CONSTRAINT_TYPE COLUMN_NAME
------------------------------ --------------- -----------------------------
SYS_C0051838 C A
SQL> alter table test modify constraint SYS_C0051838 enable validate;
Table altered
SQL> desc test;
Name Type Nullable Default Comments
---- ------ -------- ------- --------
A NUMBER
B NUMBER Y
oracle字段 not null不一致
最新推荐文章于 2024-08-08 15:36:21 发布