1. 程式人生 > >oracle 遊標迴圈刪除表資料 sql

oracle 遊標迴圈刪除表資料 sql

 

  declare
  cursor table_user is
    select table_name      from user_tables     where table_name not like 'resthome';
   table_name varchar(40);
begin
  open table_user;
  fetch table_user
    into table_name;

  while table_user%found

   loop
    --dbms_output.put_line('delete from '||table_name);
    ---執行拼接字串
    execute immediate  'delete from '||table_name;
    fetch table_user
      into table_name;
  end loop;
  close table_user;
  commit;
end;