ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Tom's tools---tkprof.sql

Tom's tools---tkprof.sql

原创 Linux操作系统 作者:jlandzpa 时间:2019-03-10 14:45:04 0 删除 编辑
..
drop table c1;
drop table c2;
drop table p1;
drop table p2;
set echo on
set timing on

/*
set up parent child WITHOUT constrained type...
*/
create table p1 ( x number(12) primary key);
create table c1 ( x number references p1 on delete cascade);
create index c1_idx on c1(x);

/*
set up parent child WITH constrained type...
*/
create table p2 ( x number(12) primary key);
create table c2 ( x number(12) references p2 on delete cascade );
create index c2_idx on c2(x);

/*
created some parent data...
*/
insert into p1 select rownum from all_objects;
insert into p2 select rownum from all_objects;
commit;

alter session set events '10046 trace name context forever, level 12';

/*
test BULK inserts into child
*/
insert into c1 select * from p1;
insert into c2 select * from p2;

/*
and then single row inserts...
*/
begin
for x in ( select * from p1 )
loop
for i in 1 .. 5
loop
insert into c1 values ( x.x );
end loop;
commit;
end loop;
end;
/
begin
for x in ( select * from p2 )
loop
for i in 1 .. 5
loop
insert into c2 values ( x.x );
end loop;
commit;
end loop;
end;
/

update c1 set x = x+1 where x < 1000;
commit;
update c2 set x = x+1 where x < 1000;
commit;

begin
for x in ( select * from c1 where x between 5000 and 5500)
loop
update c1 set x = x+1 where x = x.x;
commit;
end loop;
end;
/
begin
for x in ( select * from c2 where x between 5000 and 5500)
loop
update c2 set x = x+1 where x = x.x;
commit;
end loop;
end;
/

/*
now some BULK deletes with the on delete cascade
*/
delete from p1 where mod(x,2) = 0;
commit;
delete from p2 where mod(x,2) = 0;
commit;


/*
and then single row deletes
*/
begin
for x in ( select * from p1 )
loop
delete from p1 where x = x.x;
end loop;
end;
/
commit;

begin
for x in ( select * from p2 )
loop
delete from p2 where x = x.x;
end loop;
end;
/
commit;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/936/viewspace-60656/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2001-10-12

  • 博文量
    240
  • 访问量
    199531