auto increment - How to create id with AUTO_INCREMENT on Oracle? -
it appears there no concept of auto_increment in oracle, until , including version 11g.
how can create column behaves auto increment in oracle 11g?
there no such thing "auto_increment" or "identity" columns in oracle. however, can model sequence , trigger:
table definition:
create table departments ( id number(10) not null, description varchar2(50) not null); alter table departments add together ( constraint dept_pk primary key (id)); create sequence dept_seq;
trigger definition:
create or replace trigger dept_bir before insert on departments each row begin select dept_seq.nextval :new.id dual; end; /
update: identity column available on oracle 12c version, see this:
create table t1 (c1 number generated default on null identity, c2 varchar2(10));
oracle auto-increment
No comments:
Post a Comment