前端之家收集整理的这篇文章主要介绍了
oracle – 如何截断所有用户表?,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
declare
begin
for c1 in (select table_name,constraint_name from user_constraints) loop
begin
execute immediate ('alter table '||c1.table_name||' disable constraint '||c1.constraint_name);
end;
end loop;
for t1 in (select table_name from user_tables) loop
begin
execute immediate ('truncate table '||t1.table_name);
end;
end loop;
for c2 in (select table_name,constraint_name from user_constraints) loop
begin
execute immediate ('alter table '||c2.table_name||' enable constraint '||c2.constraint_name);
end;
end loop;
end;
/