Skip to Main Content

Breadcrumb

XMAS_TREE

The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.

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!

We're not taking comments currently, so please try again later if you want to add a comment.

More to Explore

Design

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