Question: What is "generated as
identity" feature in 12c, and how does "generated as
identify" compare to the concept of an Oracle sequence?
Answer: In all relational databases,
finding a unique key to identify each row has always been
problematic. Oracle first introduced "sequences
", or linear number generators" wo allow for the
specification of unique keys for tables and this has worked
With traditional sequences, the DBA has
to define the sequence and the developer had to use the
"nextval" operator in order ro insert into the table:
Now, starting with Oracle 12c, we can use the another
method, generated as identity to ensure that each row for a
table is unique. The "generated as identify" syntax is
very simplar ti the Java and DB2 equivalent.
||GENERATED AS IDENTITY
increment by 1
start with 1;
|No equivalent needed
generated as identity ,
From the example insert above, note that there is not need
to reference the "identity" column" you simply omit any
reference to it and Oracle will automatically increment the
key and insert it into the table on your behalf.
If you try to enter a value for a generated as identity
column you will get an ORA-32795 error:
customer values (1,'XXX');
insert into test values (1,'XXX')
ERROR at line
ORA-32795: cannot insert into a generated always
Oracle Training from Don Burleson
The best on site
training classes" are just a phone call away! You can get personalized Oracle training by Donald Burleson, right at your shop!
Burleson is the American Team
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
and include the URL for the page.
Copyright © 1996 - 2017
All rights reserved by
is the registered trademark of Oracle Corporation.
Remote Emergency Support provided by