oracle 一次刪除多張表的資料(未測試版)

2021-05-21 21:13:46 字數 898 閱讀 2108

spool d:/deletetb.sql;

select 'delete ' || table_name || ' where to_char(col,'||'''yyyy'''||')='||'''2007'''||';'

from user_tables

where table_name in  (select 'hs_' || lpad(rownum, '2', '0')

from dual

connect by rownum < 100);

spool off;

--類似如下

php code:

begin

for 

x in 

(select 

* from user_objects where object_name like 

'hs_%'

) loop

execute immediate 

'delete from '||x

.object_name

||' where substr(apl_date,0,4)=''2007'''

;end loop

;end

;

where object_name like 'hs_%' => where object_name like 'hs/_%' escape '/'  

測試後版本:

select 'select * from '||table_name||' where yearmonth=''201001'';'

from dba_tables where table_name like 'dw_cu_b_%';

記一次Oracle表資料刪除恢復

因為手抖沒有將開發環境切換到測試環境導致在開發環境新建的表刪除了,這張表包含很多配置資訊,而且沒有備份,特此整理出恢復過程。一 檢視 站中表 select object name,original name,partition name,type ts name,createtime,droptim...

Oracle外部表的一次維護

昨晚上在做資料庫的匯出匯入操作的時候,發現在將匯出資料匯入到新庫過程中報告如下錯誤 在檢視資料庫中關於外部表的檢視中相關資訊 select from dba directories select from select from dba external tables 發現exp userid表存在...

一次oracle大量資料刪除經歷

oracle有個資料表現在已經有2500萬條資料了,軟體用到這個表的資料時就變的特別慢,所以準備把乙個月以前的資料全部清除。我的步驟是 下邊操作都是在plsql中執行的 1 首先 將這個月的資料匯出到乙個臨時表中 這些資料是自己希望保留的 create table temptable as sele...