Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Rahul.

Asked: August 04, 2017 - 12:09 pm UTC

Last updated: August 04, 2017 - 3:07 pm UTC

Version: 12.1

Viewed 1000+ times

You Asked

Hi TOM,

if I want to create one table with identity column so can i define name for identity ?

with LiveSQL Test Case:

and Chris said...

You mean for the sequence the identity uses? No. Oracle Database generates one for you.

Though you can use a sequence as a default which is similar to an identity:

create sequence s;
create table t (
  x int generated as identity,
  y int default s.nextval
);

select column_name, data_default from user_tab_cols
where  table_name = 'T';

COLUMN_NAME  DATA_DEFAULT                     
X            "CHRIS"."ISEQ$$_197251".nextval  
Y            "CHRIS"."S"."NEXTVAL"   


PS - you need to save your LiveSQL script before you can share it!

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Design

New to good database design? Check out Chris Saxon's full fundamentals class.