--创建表
create table TempBDCQZ
(
BSM INTEGER not null primary key,
ZSBSM INTEGER not null,
YWH VARCHAR2(50)
)
--创建序列
create sequence for_test
start with 1
increment by 1
maxvalue 99999999
nocycle;
--使用触发器将序列应用到 TempBDCQZ.bsm
create or replace trigger "TRG_TempBDCQZ" before insert or update on TempBDCQZ for each row
begin if :new.bsm>0 then null; else select for_test.nextval into :new.bsm from dual; end if; end;
--批量创建大数据 ,bsm使用序列
declare n int;
begin
n:=0;
while n<8
loop
insert into TempBDCQZ ( zsbsm,ywh ) select zsbsm,ywh from TempBDCQZ;
n:=n+1;
End loop;
end;
--查看结果
select * from tempbdcqz;