|
- Data Pump
Oracle 10g의 기능인 Data Pump는 Oracle Database data와 metadata의 이동을 위한
DBMS_DATAPUMP 패키지를 통하여 상당히 빠른 Data Pump infrastructure를 제공하고 있다.
export와 import의 향상된 유틸리티이다.
export와 import는 사용도 편리하고 성능도 뛰어나지만 속도가 느리고 작업시간을 예측하기도 어려운 등의 여러 가지 단점을 가지고 있었지만 datapump는 뛰어난 속도 향상과 사용자의 편의성을 가지고 있습니다.
oracle directory를 통해 접근한다.
----- impdp ------
1. directory 생성
create or replace directory db_backup as '/db_backup';
2. directory 확인
select * From dba_directories;
3. 권한 부여
grant read, write on directory db_backup to scott;
4. expdp 실행
expdp system/pwd directory=db_backup schemas=scott dumpfile=scott_expdp_20120101.dmp logfile=scott_expdp_20120101.log;
5. 해당경로에 dmp 파일 확인
----- expdp ------
drop user scott cascade;
drop tablespace scott_data including contents and datafiles;
drop tablespace scott_index including contents and datafiles;
1. tablespace 생성
create tablespace scott_data datafile 'D:\oradata\user_data01.dbf' size 50M
extent management local uniform size 1M;
create tablespace scott_index datafile 'D:\oradata\user_index01.dbf' size 50M
extent management local uniform size 1M;
2. user 생성
create user scott
identified by "tiger"
default tablespace user_data
temporary tablespace temp
quota unlimited on scott_data
quota unlimited on scott_index;
3. 접속,리소스 권한 부여
grant connect, resource to scott;
4. impdp 실행
impdp system/pwd directory=db_backup schemas=scott dumpfile=scott_expdp_20120101.dmp logfile=scott_impdp_20120101.log
5. data 확인
6. exp imp 의 경우 간혹 index가 data tablespace 로 들어가는 경우가 있다.
datadump는 잘 들어가는 듯...
다음 쿼리 실행해서 나온 결과 실행하면 된다.(index rebuild)
select 'alter index '||index_name||' rebuild tablespace SCOTT_INDEX;' from user_indexes
where tablespace_name='SCOTT_DATA';
expdp 실행모드
1.full 모드 : 데이터베이스 전체를 export 받을수있다
2.schema 모드 : schema 파라미터를 사용하여 특정 스키마 전체를 받을수있다.
3.tablespace 모드 : 해당 tablespace에 속한 모든 테이블을 받을수있습니다.
transport_tablespace파라미터를 사용한다면 테이블과 테이블스페이스의 메타데이터도 받을수있습니다.
단!!! transport_tablespace를 사용하려면 양쪽 OS가 같고 blocksize와 characterset 이 같아야 합니다.
expdp 파라미터
- directory : 디렉토리 오브젝트를 지정하여 덤프 파일의 위치로 로그파일의 위치 지정가능
- dumpfile : 파일시스템에 저장될 덤프파일의 이름을 지정해주는 파라미터로 파일이 여러개로 나누어질때 %U로 파일 이름을 고유하게 구분해 줄수 있다.
- filesize : 한개 파일의 최대 크기를 지정
- parfile : 파라미터 파일을 참조하여 사용
- logfile/nologfile : 작업내용을 저장 할 로그파일명을 지정
- content: 작업시 어떤 내용을 포함시킬 것인가를 결정
All :테이블과 메타데이터를 모함한 모든것
DATA_only:테이블 데이터만 포함
Metadata_only:메타데이터만 포함
- exclude/include : 작업시 원하는 오브젝트만 선택하여 작업
ex)scott schema 의 모든 것을 expdp 받되 emp,dept 테이블만 제외할경우
expdp scott/tiger directory=datapump dumpfile=scott01.dmp schemas=scott exclude=table:\"IN\(\'EMP\',\'DEPT\'\)\"
- query : 특정 조건에 맞는 데이터만 expdp 를 수행할 경우
- sample : 데이터를 export할때 데이터가 너무 많을 경우 특정 퍼센트를 지정해서 추출 범위는 0.000001~100%
- network_link : 원격으로 expdp할때 이기능은 DB link가 생성되어있어야 합니다
- encrytion_password : expdp받은 테이블중에 특정 컬럼이 encryption되어있는경우 작업시 암호를 설정가능
- job_name : 작업 수행시 job에 이름을 설정할수있습니다. 설정을 하지않으면 오라클이 자동으로 설정
- status : 이 파라미터는 작업시 갱신된 내용을 status 설정된 시간 간격으로 진행상태를 보여주게 됩니다.
- parallel : 작업수행시 프로세스를 몇 개를 사용 할 것인가를 지정하는 파라미터입니다. 주의할점은 지정된 개수만큼의 데이터 파일을 만들어 주어야하는데 앞에서 배운 %U 옵션을 주면 자동으로 생성
- attach : 일시 중단된 작업에 다시 접속 할때 사용
ex) expdp scott/tiger job_name=dp1
attach 모드 옵션
add_file : 덤프파일을 추가
exit:job 의 작업에서 빠져나감
kill_job : 해당 작업을 삭제
parallel : 현재 작업중인 프로세스의 개수를 조절
start_job :중단된 작업을 다시 시작
status : 현재 작업을 모니터링하는 시간조절
stop_job : 현재 작업을 중단
impdp 관련 파라미터
impdp 관련 파라미터는 거의 expdp와 비슷한 것이 많아서 중복설명은 생략하겟으니 expdp를 참고하세요
- content
- include
- exclude
- table_exists_action : impdp 에 만 있는 옵션으로 동일한 이름의 테이블이 존재할 때 테이블의 데이터가 다를 경우가 있습니다.
skip : 같은 테이블을 만나면 건너뛰고 다음테이블을 impdp 함
append : 같은 테이블을 만나면 기존내용에 데이터를 추가
truncate : 같은 테이블을 만나면 기존 테이블을 truncate 하고 새로 impdp 합니다
drop : 기존 테이블을 drop하고 테이블을 새로 만들어서 새로운 내용을 impdp 합니다
- remap_schema : scott user로 expdp 받은 테이블을 다른 유저로 impdp 할때 사용
ex)impdp system/oracle directory=datapump dumpfile=scott.dmp schemas=scott include=table:\"\=\'emp\'\" remap_schema=scott:hr
- remap_datafile : 기존 서버의 데이터파일 정보를 이전 후 서버의 데이터파일로 매핑해주는 파라미터
expdp 된 덤프 파일 안에 데이터 파일 정보를 가지고 있는 경우만 사용가능
ex)impdp system/oracle full=y directory=datapump dumpflie=full01.dmp remap_datafile='/data1/users01.dbf':'/data2/users01.dbf'
- remap_tablespace : 기존 테이블스페이스에서 다른 테이블스페이스로 테이블을 impdp시킬때 사용
ex) impdp system/oracle directory=datapump dumpfile=scott.dmp remap_tablespace ='users1':'users2' schemas=scott;
ex) impdp system/oracle directory=datapump dumpfile=scott.dmp remap_tablespace =users1_data:users2_data, users1_index:users2_index schemas=scott;
ex) impdp system/oracle directory=datapump dumpfile=scott.dmp schemas=scott remap_schema=scott:scotttest remap_tablespace=users1_data:users2_data include=table:"in ('EMP','DEPT','SAL')" logfile=scott_impdp.log
ex) impdp system/oracle directory=datapump dumpfile=scott.dmp schemas=scott remap_schema=scott:scotttest remap_tablespace=users1_data:users2_data include=table:\"in \(\'EMP\',\'DEPT\',\'SAL\'\)\" logfile=scott_impdp.log
ps : 테이블명 대문자~~
- network_link
|