OracleDB12c New Feature: Use of Sequence Value in Column DEFAULT

Happy 4th of July!

In the 12c new feature a day series, I discussed the “Identity Column” feature yesterday. Extension to that feature is now you can use sequence  pseudo-column NETXTVAL or CURRVAL as DEFAULT value for a column in table definition. In the prior releases to be able to do this, a trigger and some coding was required…

If the sequence is owned by another user, appropriate access should be granted on the sequence [privilege, synonym, qualify with schema name].

You can have only one IDENTITY column per table, buy you may create more than one column with DEFAULT sequence values.

Example:

CREATE TABLE T1 (
X1 NUMBER DEFAULT SCOTT.MYSEQ.NEXTVAL,
X2 VARCHAR2);