问题处理思路: 1. 先将数据库中涉及到外键约束的表置为无效状态 2.待清除完所有表数据后再将外键约束的表置为可用状态 具体实现脚本: declare begin for vv_sql in (SELECT ALTER TABLE || table_name || DISABLE CONSTRAINT || CONSTRAINT_NAME alter_sql
问题处理思路:
1. 先将数据库中涉及到外键约束的表置为无效状态
2.待清除完所有表数据后再将外键约束的表置为可用状态
具体实现脚本:
declare
begin
for vv_sql in (SELECT 'ALTER TABLE '|| table_name ||' DISABLE CONSTRAINT ' || CONSTRAINT_NAME alter_sql FROM USER_CONSTRAINTS
where CONSTRAINT_TYPE = 'R')
loop
execute immediate vv_sql.alter_sql;
end loop;
execute immediate 'truncate table 表名;
................. ---此处省略,可用写多个executesql语句
for vv_sql in (SELECT 'ALTER TABLE '|| table_name ||' ENABLE CONSTRAINT ' || CONSTRAINT_NAME alter_sql FROM USER_CONSTRAINTS
where CONSTRAINT_TYPE = 'R')
loop
execute immediate vv_sql.alter_sql;
end loop;
end;
/