Getting nextval from an identity column support sequence

I have a table column declared as follows:

file_id number(10) generated always as identity primary key,

Is it possible to programmatically get currval/ <T22> from my base sequence without actually looking in SYS. tables to get the name of the sequence, and then using execute immediatefor that name?

+4
source share
1 answer

Is it possible to programmatically get currval / nextval from my supporting sequence without actually learning SYS

, . USER_SEQUENCES , , USER_TAB_IDENTITY_COLS . :

create table t1(
  c1 number  generated always as identity primary key
);

insert into t1 values(default);

select *  from t1;

C1
-----
    1

, Oracle , ISEQ$$_92984.

select "ISEQ$$_92984".nextval from dual;

NEXTVAL
-------
     2

insert into t1 values(default);

select * from t1;

 C1
 ---------
         1
         3
+6

Source: https://habr.com/ru/post/1677689/


All Articles