赞
踩
- create sequence seq_test_insert
- minvalue 1
- maxvalue 999999999999999999999999
- start with 1
- increment by 1
- cache 20;
- INSERT INTO table1 (SID, field1, field2 )
-
- SELECT seq_test_insert.nextval, t2.field1, t2.field2 FROM table1 t2
- --创建表的触发器(用来触发id自增)
- --DROP SEQUENCE test_seq;
-
- create sequence test_seq start with -1 increment by -1;
-
- --创建表的触发器(用来触发id自增)
- --drop trigger test_trigger ;
-
- create or replace trigger test_trigger
- before insert or update on table
- for each row
- when (new.sid is null)
- begin
- select test_seq.nextval into :new.sid from dual;
- end;
然后再执行插入语句
这里没有主键
insert into table (field1,field2) values (val1, val2);
转载地址:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。