'recyclebin'에 해당되는 글 2건

  1. 2016.10.20 oracle recyclebin 기간별로 지우기
  2. 2016.07.28 recyclebin 원하는 날짜만큼 삭제하기


어떠한 이유로 인해 Recylebin 으로 drop 된 (실제로는 rename만 된것이지만) 객체들을 일정한 기간 만큼만 지우고자 하는 경우가 있을 것이다.


해당 경우 아래와 같이 하면 된다.


보기 예 1 )


- 7일이 경과한  Table 을 삭제하고자 할때


select 'purge table '||owner||'."'||OBJECT_NAME||'";' 

from dba_recyclebin where type='TABLE' and to_date(droptime,'YYYY-MM-DD:HH24:MI:SS')<sysdate-7;


'PURGETABLE'||OWNER||'."'||OBJECT_NAME||'";'

------------------------------------------------------------------------------------------------------------------------

purge table WMSYS."BIN$PgNXeTuLWoPgU24AEKyH3g==$0";

purge table WMSYS."BIN$PgRouDktJGngU24AEKx4sg==$0";

purge table WMSYS."BIN$PgTrksKrSP3gU24AEKzvyw==$0";

Elapsed: 00:00:00.02


보기 예 2 )


- 5분이 경과한 Table 을 삭제하고자 할때


select 'purge table '||owner||'."'||OBJECT_NAME||'";' 

from dba_recyclebin where type='TABLE' and to_date(droptime,'YYYY-MM-DD:HH24:MI:SS')<sysdate-(5/(24*60));


끝.

Posted by pat98

 

휴지통에서 원하는 날짜만큼 명령어로 딱딱 지우는 명령어는 없고 명령어로 조건을 줘서 스크립트를 뽑아내는 방법이 있긴 하다.

 

1. 7일꺼만 남기고 다 지우기

 

spool purge_table_older_than_7_days.sql
select 'purge table '||owner||'."'||OBJECT_NAME||'";'
from dba_recyclebin where type='TABLE' and to_date(droptime,'YYYY-MM-DD:HH24:MI:SS')<sysdate-7;
spool off;

 

2. 5분 보다 오래된거 다 지우기

 

spool purge_table_older_than_5_minutes.sql
select 'purge table '||owner||'."'||OBJECT_NAME||'";'
from dba_recyclebin where type='TABLE' and to_date(droptime,'YYYY-MM-DD:HH24:MI:SS')<sysdate-(5/(24*60));
spool off;

spool purge_table_older_than_5_min.txt
@purge_table_older_than_5_minutes.sql
spool off;

 

------------------------------------------------------------

 

나머지 조건들은 필요에 따라 수정해서 상황에 맞게 쓰면 될듯.

Posted by pat98
이전버튼 1 이전버튼

05-09 04:31
Flag Counter
Yesterday
Today
Total

글 보관함

최근에 올라온 글

달력

 « |  » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

최근에 달린 댓글