declare
towner varchar2(30);
begin
towner := '&user';
/*
先禁用表上所有的外鍵約束
*/
for c in (select 'alter table '||owner||'.'||t.table_name || ' disable CONSTRAINT '||t.constraint_name as csql from all_constraints t where t.owner = towner? and t.constraint_type='R')
loop
begin
execute immediate c.csql;
dbms_output.put_line(c.csql|| '? ...........√');
exception
when others then
dbms_output.put_line(c.csql||' ..........ⅹ');
end;
end loop;
/*
開始清理表數據
*/
for c in (select owner,object_name,'truncate table '|| owner||'.'||object_name as dsql
from all_objects? where object_type='TABLE'? and owner = towner) loop
begin
execute immediate c.dsql;
dbms_output.put_line(c.dsql || '? ...........√');
exception
when others then
dbms_output.put_line(c.dsql||' ..........ⅹ');
end;
end loop;
/*
啟用表上的外鍵約束
*/
for c in (select 'alter table '||owner||'.'||table_name || ' enable CONSTRAINT '||t.constraint_name as csql from all_constraints t where t.owner = towner? and t.constraint_type='R')
loop
begin
execute immediate c.csql;
dbms_output.put_line(c.csql|| '? ...........√');
exception
when others then
dbms_output.put_line(c.csql||' ..........ⅹ');
end;
end loop;
end;
關鍵詞標簽:ORACLE
相關閱讀
熱門文章
Oracle中使用alter table來增加,刪除,修改列的語法
oracle中使用SQL語句修改字段類型-oracle修改SQL語句案例
誤刪Oracle數據庫實例的控制文件
為UNIX服務器設置Oracle全文檢索
人氣排行 oracle中使用SQL語句修改字段類型-oracle修改SQL語句案例 Oracle中使用alter table來增加,刪除,修改列的語法 ORACLE SQL 判斷字符串是否為數字的語句 ORACLE和SQL語法區(qū)別歸納(1) oracle grant 授權語句 ORACLE修改IP地址后如何能夠使用 如何加速Oracle大批量數據處理 Oracle刪除表的幾種方法