declare
num number(12) :=0;
begin
begin
execute immediate
'drop table tb1';
exception
when
others
then
null;
end;
execute immediate
'create table tb1(
aa number,
bb number)';
for num in select * from tb1 loop
insert into tb1(aa,bb) values(num,num);
end loop ;
commit;
end;
num number(12) :=0;
begin
begin
execute immediate
'drop table tb1';
exception
when
others
then
null;
end;
execute immediate
'create table tb1(
aa number,
bb number)';
for num in select * from tb1 loop
insert into tb1(aa,bb) values(num,num);
end loop ;
commit;
end;
博客展示了一段SQL代码,先尝试删除tb1表,若出现异常则忽略。接着创建tb1表,包含aa和bb两个数值类型字段。然后通过循环将tb1表中的数据插入自身,最后提交事务。

被折叠的 条评论
为什么被折叠?



