Oracle删除相似表名的表数据


例如数据库用户名为username   要删除所有表名以TBL_开头的表的数据:

----------------------------------------------------

declare
cursor c1 is select table_name
               from dba_tables
              where owner='USERNAME';
begin
for c2 in c1 loop
if instr(c2.table_name,'TBL_')=1 then

execute immediate 'delete from USERNAME.'||c2.table_name;

end if;
end loop;
end;

----------------------------------------------------

注意大小写:where owner='USERNAME';

相关内容