oracle 自增列设置

序列

create sequence sq_1
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 2000;

 

触发器

create or replace trigger 触发器名字
  before insert on 表名  
  for each row
declare
  -- local variables here
begin
   SELECT sq_1.nextval
  INTO :NEW.列名
  FROM DUAL;

end 触发器名字;

 

SQL语句

insert into gd(id) values(sq_1.nextval);

 

posted @ 2015-08-14 12:16  GD_熬夜  阅读(528)  评论(0编辑  收藏  举报