批量 truncate 表

如果某个用户下所有表或指定表中所有的数据已确定不再需要,此时可以进行批量 truncate


declare cursor cur_trunc
is
select table_name from user_tables;
begin
for cur_del in cur_trunc loop
execute immediate 'truncate table '||cur_del.table_name;
end loop;
end;

由此可以引申到,删除表 drop 删除表中数据 delete 将 truncate 替换即可

select table_name from user_tables;
此句中可以对在后面加where 条件 指定 like 查询某类的表

原文地址:https://www.cnblogs.com/tianmingt/p/4447773.html