ORA-01400:无法将NULL插入,ORACLE中DAFAULT和DAFAULT ON NULL的区别

建表:

create table aims_test(
id number(16),
birthday date default on null sysdate not null,
happlybirth date default sysdate not null,
happyday date default on null sysdate
)
insert into aims_test(id) values (2); -- 插入3个时间
insert into aims_test(id,birthday) values (3,null); --插入3个时间
insert into aims_test(id,birthday,happlybirth) values (4,null,null); --报错,因为是default 不是default on null

总结:

default on null 会自动将字段变成not null,不需要再设置not null, default不会

default on null 当插入null的时候变成默认值,default会报错

当插入时不指定列名时insert into aims_test(id) values (2),default和default on null 都会将字段设置成默认值。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章