Oracle 10gで全てのテーブルをクリアする用「PL/SQL」スクリプト(ロールバック可能)

PL/SQLコード:
/**
全てのtableをクリア(ロールバック可能)
**/
declare
— tableのカーソルを指す
cursor c_t is
select table_name
from user_tables;

table_name user_tables.table_name%type;
begin
open c_t;
loop
fetch c_t into table_name;
exit when c_t%notfound;

— 誤操作を減らすためにdeleteを使用する
execute immediate 'delete from ' || table_name;
end loop;
close c_t;
end;

DataBase

Posted by arkgame