批量刪除表

2021-05-10 14:06:30 字數 1023 閱讀 3629

--批量刪除表

--方法1

select 'truncate table ' || object_name || ';'

from user_objects

where object_name like 'ky_prj_temp%'

and object_type = 'table';

--command windows 下執行查詢結果

--方法2

--select * from tab

select 'truncate table ' || t.tname || ';'

from tab t

where t.tname like 'ky_prj_temp%' and t.tabtype = 'table';

----

--附  輸出表

---set serveroutput on;

create or replace procedure dada_truncate_tables(tablename in string) as

table_names varchar2(4000);

--v_pos number :=1;

cursor c is select tname from tab where upper(tname) like upper(tablename)||'%' ;

begin

for cc in c loop

--execute immediate ' truncate table '||cc.tname;

table_names := cc.tname||','||table_names;

--dbms_output.put_line(cc.tname);

if length(table_names) > 200 then

dbms_output.put_line(table_names);

table_names :='';

end if;

end loop;  

end;

oracle批量刪除表

如下 declare 定義臨時變數用於儲存每一條刪除sql tmp sql varchar2 4000 定義游標變數用於儲存所有的刪除sql cursor drop sql is 查詢拼接出所有刪除sql select drop table table name from user tables w...

ORACLE批量刪除表

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

批量刪除表的sql語句

批量刪除表的sql語句,當然這種刪除需要表的名字有相同的字首.declare table nvarchar 300 declare tmpcur cursor for select name from sys.objects where type u and name like n hsupa op...