[오라클] 데이터 백업 없이 drop 되어진 테이블 복구하기

심심이·2024년 3월 1일

oracle

목록 보기
26/40
  --  flashback drop ==> drop 되어진 테이블을 복구가 가능하도록 만들어 주는 것이다.
   
   ---- !!!! 테이블을 삭제시 휴지통에 버리기 !!!! ----

create table tbl_exam_01(name  varchar2(20));
insert into tbl_exam_01(name) values('연습1');
commit;

create table tbl_exam_02(name  varchar2(20));
insert into tbl_exam_02(name) values('연습2');
commit;

create table tbl_exam_03(name  varchar2(20));
insert into tbl_exam_03(name) values('연습3');
commit;

create table tbl_exam_04(name  varchar2(20));
insert into tbl_exam_04(name) values('연습4');
commit;

create table tbl_exam_05(name  varchar2(20));
insert into tbl_exam_05(name) values('연습5');
commit;
  
create table tbl_exam_06(name  varchar2(20));
insert into tbl_exam_06(name) values('연습6');
commit;

drop table tbl_exam_01;  --> tbl_exam_01 테이블을 영구히 삭제하는 것이 아니라 휴지통에 버리는 것이다. 
-- Table TBL_EXAM_01이(가) 삭제되었습니다.

select * from tab; 
-- 결과물에서 tname 컬럼에 BIN$로 시작하는 것은 휴지통에 버려진 테이블이다. 

drop table tbl_exam_02;  --> tbl_exam_02 테이블을 영구히 삭제하는 것이 아니라 휴지통에 버리는 것이다. 
-- Table TBL_EXAM_02이(가) 삭제되었습니다.

select * from tab; 
-- 결과물에서 tname 컬럼에 BIN$로 시작하는 것은 휴지통에 버려진 테이블이다. 

select * 
from tbl_exam_01;
-- ORA-00942: 테이블 또는 뷰가 존재하지 않습니다

select * 
from tbl_exam_02;
-- ORA-00942: 테이블 또는 뷰가 존재하지 않습니다


select * 
from "BIN$0VwU7HpESIGTzzrdCFSloA==$0";


select * 
from "BIN$QI8hJR0dQda9apVjsOEiXw==$0";

select * 
from "BIN$hESdXWrUTkya5v0YInh6Dg==$0";

select * 
from "BIN$zx32iCVhS3215NV3PjD2Vw==$0";


---- !!!! 휴지통 조회하기  !!!! ----
  
select *
from user_recyclebin;
  
---- !!!! 휴지통에 있던 테이블을 복원하기  !!!! ----
flashback table TBL_EXAM_01 to before drop;
--- Flashback을(를) 성공했습니다.
-- TBL_EXAM_01 은  select * from user_recyclebin; 에서 보았던 original_name 컬럼에 나오는 것이다.

select *
from TBL_EXAM_01;


---- !!!! 휴지통에 있던 테이블을 영구히 삭제하기  !!!! ----

select *
from user_recyclebin;

purge table TBL_EXAM_02;
-- TBL_EXAM_02 은 user_recyclebin 에서 보여지는 original_name 컬럼에 나오는 것이다.
--table이(가) 비워졌습니다.


---- !!!! 휴지통에 있던 모든 테이블을 영구히 삭제하기  !!!! ----



drop table tbl_exam_03; -- 휴지통에 있는 테이블 삭제 
-- Table TBL_EXAM_03이(가) 삭제되었습니다.

drop table tbl_exam_04; -- 휴지통에 있는 테이블 삭제 
-- Table TBL_EXAM_04이(가) 삭제되었습니다.

purge recyclebin; -- 휴지통에 있는 모든 테이블을 영구히 삭제하기

select *
from user_recyclebin;

select * from tab; -- BIN$로 시작하는 것이 아무것도 없다.

select * 
from tbl_exam_05;

---- *** 테이블을 영구히 삭제하기 ---> drop 되어진 테이블은 복원이 불가하다. *** ---
DROP TABLE TBL_EXAM_05 PURGE;
--Table TBL_EXAM_05이(가) 삭제되었습니다.

select * from user_recyclebin; 
profile
개발하는 심심이

0개의 댓글