在oracle中,创建100个表,表中只有一列number。

要完成的操作是,1插入到table1中,2插入到table2中....100插入到table100中,101插入到table1中...据说要用到动态sql,求助大神啊,怎么做啊这个题~

第1个回答  2014-06-12
declare
ls_table_name varchar2(200);
begin
for i in 1..100 loop

begin
ls_table_name:='table'||to_char(i);

execute immediate 'create table '||ls_table_name||' (id number(8))';

execute immediate 'Insert into '||ls_table_name||' (id) values(:1)' using i;

exception when others then rollback;

end;
end loop;

commit;
end;
相似回答