天天看点

Oracle批量删除表脚本

今天导库前忘了建表空间,之前导的数据都瞎了,需要删除。

先得删除约束,再删除表,下面是脚本

删除外键约束

Begin

  for t in (select * from user_constraints ) loop

  execute immediate  'alter table '||t.table_name||' drop constraint '||t.constraint_name||' and constraint_type=R;';

  end loop;

end;

删除表

Begin

  for t in (select table_name from user_tables ) loop

execute immediate 'drop table ' || t.table_name;

  end loop;

end;