[SQL] 데이터 복구 - FLASHBACK DROP

·2025년 7월 15일
0

SQL

목록 보기
116/126

실습1. emp 테이블에 sal 에 인덱스를 생성하시오

create index emp_sal
 on emp(sal);

실습2. emp 테이블에 job 에 인덱스를 생성하시오

create index emp_job
 on emp(job);
 
-- index_name 조회
select index_name
 from user_indexes
 where table_name='EMP';

실습3. emp 테이블을 drop 하시오

drop table emp;

-- index도 같이 drop 되어서 조회 안됨
select index_name
 from user_indexes
 where table_name='EMP';

💡 emp table을 drop 하면 관련 index나 제약들이 모두 drop 됨

실습4. drop 된 emp 테이블이 휴지통에 있는지 확인하고 휴지통에서 복구하시오

휴지통 조회(show recyclebin)

show recyclebin;


EMP_JOB       BIN$9HANvoBuRYqVa/oHWqeYLw==$0 INDEX       2025-07-15:11:57:00 
EMP_SAL       BIN$ltgwXZ0UTX6ahXTbuQ/wTw==$0 INDEX       2025-07-15:11:57:00 
EMP           BIN$b2AN+vEaRBerdfK5x5i0Rw==$0 TABLE       2025-07-15:11:57:00 
flashback table emp to before drop;
select * from emp;

select index_name, column_name
 from user_ind_columns
 where table_name='EMP';
 
alter index "BIN$ltgwXZ0UTX6ahXTbuQ/wTw==$0" rename to emp_sal;
alter index "BIN$9HANvoBuRYqVa/oHWqeYLw==$0" rename to emp_job;

문제. dept 테이블에 인덱스를 1개를 생성하고 dept 테이블을 drop 하고 복구하는데 인덱스 이름도 제대로 복구하시오

create index dept_loc
 on dept(loc);

drop table dept;

select index_name
 from user_indexes
 where table_name='DEPT';
 
show recyclebin;

flashback table dept to before drop;

select * from dept;

select index_name, column_name
from user_ind_columns
where table_name='DEPT';

alter index "BIN$35uHuU5pRpunYWUsEQwEBw==$0" rename to dept_loc;

0개의 댓글