建表:
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 都會將字段設置成默認值。