Fork me on GitHub
creasypita
许上等愿 结中等缘 享下等福 择高处立 寻平处住 向宽处行

--创建表
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;

posted on 2018-03-23 12:23  creasypita  阅读(536)  评论(0编辑  收藏  举报