반응형
/********************************************************************************************
-- Title : [10g] Transportable Tablespace 사용법 - ver.dbrang
-- Reference : dbrang.tistory.com
-- Key word : tts transport transport_tablespace 트랜스포터블 테이블스페이스
********************************************************************************************/
/********************************
-- 테이블스페이스 생성
********************************/
-- TS 생성
CREATE TABLESPACE ts_data0 /* Default Template */
DATAFILE '/home/oracle/oradata/ts_data_0.dbf' size 100M
               AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL AUTOALLOCATE;

-- TS 확인
select d.tablespace_name, d.file_name
     , to_char(d.bytes/1024/1024, '999,999.00') "Size(MB)"
     , to_char((d.increment_by * 8), '999,999.00') "Increment(KB)"
     , to_char(d.maxbytes/1024/1024, '999,999.00') "MaxSize(MB)"
     , d.status, v.status "Online"
     , v.enabled, d.autoextensible
from dba_data_files d
inner join v$datafile v
on d.file_name = v.name
order by d.tablespace_name, d.file_name;

-- 테이블 생성
create table scott.emp_tts
as
select * from scott.emp;

-- 테이블의 TS 이동
alter table scott.emp_tts move tablespace ts_data0;

-- TS 이동 확인
select * from dba_tables
where owner = 'SCOTT' and table_name = 'EMP_TTS';

-- 데이터 입력
insert into scott.emp_tts
select * from scott.emp;

-- 입력 확인
select * from scott.emp_tts;
 

/********************************
-- TTS 수행
********************************/
-- 해당 TS 읽기 전용 전환
alter tablespace ts_data0 read only;

-- 읽기 전용 확인
select tablespace_name, status from dba_tablespaces;

-- EXPORT(transport_tablespace=y)
$ exp userid=\'ttt/ttt as syssdba\' file=/home/oracle/EXP/tts.dmp \
      transport_tablespace=y tablespaces=ts_data0
     
-- 기존 TS 삭제(테스트 위해)
drop tablespace ts_data0 including contents;

-- 파일 이동
$ cp /home/oracle/oradata/ts_data_0.dbf \
     /home/oracle/oradata/TEST/ts_data_0.dbf

-- 파일 이동 확인
$ ll cd /home/oracle/oradata/INFRAORA/

-- IMPORT(transport_tablespace=y)
$ imp \'ttt/ttt as sysdba\' file=/home/oracle/EXP/ttt.dmp \
      transport_tablespace=y datafiles='/home/oracle/oradata/TEST/ts_data_0.dbf'

-- 테이블스페이스 생성 확인
select * from dba_tablespaces
where tablespace_name = 'TS_DATA0';

-- 테이블 확인
select * from scott.emp_tts;

-- 이동된 테이블스페이스 읽기/쓰기 모드 변경
alter tablespace ts_data0 read write;
반응형

+ Recent posts