oracle清空多张表数据

清空表数据

begin
  for i in (select * from user_tables t where t.table_name like '%P_TEST%') loop
    execute immediate 'truncate table ' || i.table_name;
  end loop;

end;


begin
  for i in (select * from user_tables t where t.table_name in ('P_TEST','P_TEST2')) loop
    execute immediate 'truncate table ' || i.table_name;
  end loop;

end;

拼成清空表数据

select 'truncate TABLE '||TABLE_NAME||';' from user_tables where table_name in ('P_TEST','P_TEST2');

猜你喜欢

转载自zihai367.iteye.com/blog/2262576