oracle批量刪除表

2021-07-09 23:29:42 字數 642 閱讀 5744

**如下:

declare

//定義臨時變數用於儲存每一條刪除sql

tmp_sql varchar2(4000);

//定義游標變數用於儲存所有的刪除sql

cursor drop_sql is

//查詢拼接出所有刪除sql

select

'drop table ' | table_name from user_tables where regexp_instr(table_name,'ac|bd') > 0;

begin

//開啟游標變數

open drop_sql;

//開始迴圈

loop

//將游標變數現在的sql賦值到臨時變數

fetch drop_sql into tmp_sql;

//如果游標變數為空,那麼推出迴圈

exit when drop_sql%notfound;

//執行表刪除sql

execute immediate tmp_sql;

//迴圈結束

endloop;

//關閉游標變數

close drop_sql;

//結束

end;

ORACLE批量刪除表

我們在使用資料庫時可能會建立很多臨時表,時間長了這些臨時表會佔很大的空間所以我們要定期對自己不用的臨時表進行清理,下面介紹兩個我自己經常用的語句 方法一 簡單粗暴 通俗易懂 select drop table table name from user tables where table name ...

oracle批量刪除

專案中有個需求需要每個月末定時去刪除一張表裡的歷史資料,剛開始就寫了乙個簡單的delete語句,然後起乙個job定時去呼叫,後來被告知歷史資料量很大,所以從效能和安全上考慮對sql進行了如下修改 declare cursor id key cursor is select id key from x...

批量刪除表

批量刪除表 方法1 select truncate table object name from user objects where object name like ky prj temp and object type table command windows 下執行查詢結果 方法2 sel...