oracle数据库中删除某用户下所有表的SQL语句

上一篇 / 下一篇  2011-01-18 17:04:28 / 个人分类:日常问题

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 'alter table ' || table_name || ' enable constraint ' ||
       constraint_name || ';'
from user_constraints
where constraint_type = 'R';
执行所有约束启用命令。

TAG:

 

评分:0

我来说两句

Open Toolbar