Can we create a table having an auto increment column on Oracle 12c without using a sequence?
meda Changed status to publish 07/03/2022
Yes, it is possible to create a table having an identity column.And it enables us to automatically insert data on primary column of a table without the need of an oracle sequence database object .
We use the GENERATE AS IDENTITY clause to create the identity column.
Example:
SQL> conn mereba/mereba@orcl Connected. --- create a table with autoincrement column SQL> create table sttms_cust_account( 2 cust_no number generated as identity 3 ,ac_desc varchar2(30 char)); Table created. ---insert data SQL> insert into sttms_cust_account(ac_desc) values('Messi Dave'); 1 row created. --- view the data SQL> select * from sttms_cust_account; CUST_NO AC_DESC ---------- ------------------------------ 1 Messi Dave SQL>
meda Edited answer 21/02/2022