Oracle自增ID的解决办法

来源:互联网 发布:vivo网络助手在哪里? 编辑:程序博客网 时间:2024/03/28 21:14

首先创建一个索引,然后创建一个触发器
索引的名字: SEQ_tproduct

触发器的名字: addid

表名:tproduct

自增列名:pid

create sequence SEQ_tproduct                              

minvalue 1

start with 1

increment by 1

nocache;

create or replace trigger addid

before insert on tproduct

for each row 51Testing

begin
select SEQ_tproduct.nextval into :new.pid from dual;
end;

原创粉丝点击