Home > front end >  Alter primary key in oracle to NUMBER GENERATED ALWAYS AS IDENTITY
Alter primary key in oracle to NUMBER GENERATED ALWAYS AS IDENTITY

Time:02-21

Is it possible to change the primary key identity in oracle from GENERATED BY DEFAULT ON NULL AS IDENTITY to GENERATED ALWAYS AS IDENTITY

Thanks.

CodePudding user response:

Yes; run

alter table your_table modify pk_column generated always as identity;

For example:

SQL> create table a1
  2    (id   number generated by default on null as identity,
  3     ime  varchar2(20));

Table created.

SQL> alter table a1 modify id generated always as identity;

Table altered.

SQL>
  • Related