重庆思庄Oracle、Redhat认证学习论坛

标题: oracle 12c中增加自增长字段,还有序列吗 [打印本页]

作者: 郑全    时间: 2013-8-16 00:10
标题: oracle 12c中增加自增长字段,还有序列吗
哪个能否验证一下
作者: monkeybird    时间: 2013-8-21 11:11

Identity Columns

 Improved Defaults 增强了DEFAULT, default目前可以直接指代sequence了,同时增强了default充当identity的能力

Oracle Database 12c Release 1 implements ANSI-compliant IDENTITY columns. Migration from database systems that use identity columns is simplified and can take advantage of this new functionality.

This feature implements auto increment by enhancing DEFAULT or DEFAULT ON NULL semantics for use by SEQUENCE.NEXTVAL and SYS_GUID, supports built-in functions and implicit return of default values.

 

SQL> CREATE TABLE t1 (c1 NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY, c2 VARCHAR2(10));

 

Table created.

 

SQL> INSERT INTO t1(c2) VALUES ('abc');

 

1 row created.


SQL>INSERT INTO t1 (c1, c2) VALUES (null, 'xyz');


1 row created.

 

SQL> INSERT INTO t1 (c1, c2) VALUES (default,'jkl');

 

1 row created.

 

SQL> SELECT c1, c2 FROM t1;

        C1 C2
---------- ----------
         1 abc
         2 xyz
         3 jkl






欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2