连接:http://linben.blog.51cto.com/6205951/1293619
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';
执行所有约束启用命令。
本文提供了一套针对数据库操作的实用脚本,包括禁用和启用表约束、清空表数据及删除表等步骤,适用于需要进行数据库批量维护的场景。
446

被折叠的 条评论
为什么被折叠?



