且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[20131212]12c新特性建表 属性DEFAULT ON NULL.txt

更新时间:2022-09-08 12:12:42

[20131212]12c新特性建表 属性DEFAULT ON NULL.txt

在12c上建立表可以让插入NULL等于某个特定的值.举一个例子:


SCOTT@ztest> @ver
BANNER                                                                               CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0

SCOTT@ztest> create table t (id number, name varchar2(10) default on null 'test');
Table created.    


insert into t (id) values(1);
insert into t (id,name) values(2,null);
commit ;


SCOTT@ztest> select * from t;
        ID NAME
---------- --------------------
         1 test
         2 test

--可以发现如果插入name=NULL,实际上在表中记录的是'test'.