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