oracle 字段递增 表插入数据,id自动增1 | |
create table test(id int, name varchar(32)) 2、创建序列 create sequence TID_seq minvalue 1 maxvalue 999999 start with 1 increment by 1 cache 20 ; 3、创建触发器 create or replace trigger test_tri before insert on test for each row begin select to_char(TID_seq.nextval) into :new.id from dual; end test_tri; 4、插入数据 insert into test(name) values ('a') insert into test(name) values ('b') select * from test 应该 出现 1,a 2, b |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12297816/viewspace-561463/,如需转载,请注明出处,否则将追究法律责任。