declare plsql_block varchar2(512); begin --at first,we should disable all constraint of tables for t in (select table_name, constraint_name from user_constraints where constraint_type = 'R') loop plsql_block := 'alter table ' || t.table_name || ' disable constraint ' || t.constraint_name; execute immediate plsql_block; end loop; --second,truncate table.if table has triger,wu must use truncate. for t in (select table_name from user_tables) loop execute immediate 'truncate table ' || t.table_name; end loop; --at last,we enable all constrait of tables for t in (select table_name, constraint_name from user_constraints where constraint_type = 'R') loop plsql_block := 'alter table ' || t.table_name || ' enable constraint ' || t.constraint_name; execute immediate plsql_block; end loop; end;
删除用户所有表里面的数据
猜你喜欢
转载自wwwzchen.iteye.com/blog/1485463
今日推荐
周排行