-- create parent table drop table parent; create table parent(id varchar(10),name varchar(100), primary key (id) ); -- create childen table drop table childen; create table childen(id varchar(10),pid varchar(10), name varchar(100), primary key (id) ); -- Create/Recreate primary, unique and foreign key constraints alter table CHILDEN add constraint fk_123 foreign key (PID) references parent (ID); -- add test date for parent -- Created on 2004-11-29 by GUIP declare -- Local variables here i integer; begin -- Test statements here i := 0; delete from parent; loop i := i + 1; dbms_output.put_line(i); insert into parent(id, name) values(i, 'name ' || i); if (i mod 100=0) then commit; end if; exit when i > 1000; end loop; commit; end; -- add test date for childen -- Created on 2004-11-29 by GUIP declare -- Local variables here i integer; j integer; begin -- Test statements here i := 0; delete from childen ; loop j := 0; loop i := i + 1; j := j + 1; insert into childen(id, pid, name) values(i, j, 'name ' || j); if (i mod 100=0) then commit; end if; exit when j>= 50; end loop; exit when i >= 10000 * 50; end loop; commit; end; |
欢迎光临 MariaDB社区 (http://123.56.88.72/) | Powered by Discuz! X3.2 |