oracle刪除數據庫中的所有表


1、先禁用數據庫中所有的約束

select 'alter table ' || table_name || ' disable constraint ' ||
constraint_name || ';'
from user_constraints
where constraint_type = 'R';

執行所有約束禁用命令。


2、清空所有表中的數據

select 'truncate table '||table_name||';' from user_tables;

執行所有的清表命令。

 

3、刪除所有表

select 'drop table '||table_name||';' as sqlscript from user_tables;

執行所有的刪除命令。


4、啟用數據庫中所有表的約束

select 'alter table ' || table_name || ' enable constraint ' ||
constraint_name || ';'
from user_constraints
where constraint_type = 'R';

執行所有約束啟用命令。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM