Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to find which sequence name is used in a table - Redux

SomeoneElseSep 9 2013 — edited Sep 9 2013

(The other thread was locked before I could respond, so I'm posting this here as a non-question.)

Beginning with 12c, there is now a way to associate a sequence with a table.  It's a new feature called an Identity column.

create table t

(some_id number generated as identity --< creates a system generated sequence

,name varchar2(30)

);

insert into t (name) values ('Smith');

insert into t (name) values ('Jones');

insert into t (name) values ('Anderson');

commit;

select * from t;

        SOME_ID NAME

--------------- ------------------------------

              1 Smith

              2 Jones

              3 Anderson

select table_name, column_name, data_default from user_tab_columns where table_name = 'T' and column_name = 'SOME_ID';

TABLE_NAME COLUMN_NAME DATA_DEFAULT

---------- ----------- -------------------------------------

T          SOME_ID     "C##SELSE"."ISEQ$$_91955".nextval

select * from user_sequences;

SEQUENCE_NAME

-----------------------------------

ISEQ$$_91955

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2013
Added on Sep 9 2013
7 comments
800 views