Oracle/Oracle Data Pump

Oracle Data Pump(EXPDP, IMPDP)

Soul-Learner 2008. 9. 22. 10:34

Oracle Data Pump(EXPDP, IMPDP)를 이용한 EMP 테이블 Export, Import 예

--SQL Plus에서 관리자로 로그인하여 다음과 같이 디렉토리 객체를 생성하고 이용자(scott)에게 디렉토리 사용권한을 부여한다.
create directory DPDATA1 as 'C:\dpdata1';
grant read, write on directory DPDATA1 to scott;

--위에 명시한 C:\dpdata1디렉토리를 탐색기등을 이용하여 생성한 후에,
-- 다음과 같이 커맨드 프롬프트상에서 명령하여 데이타를 엑스포트합니다.

expdp scott/tiger tables=EMPLOYEES directory=DPDATA1 dumpfile=expEMPLOYEES.dmp  job_name=EMPLOYEES_EXPORT

--위의 job_name파라미터는 내부에서 임시 테이블을 생성할 때 테이블의 이름으로 사용되고 작업이 끝나면 삭제된다.
--위와같이 명령하면 아래와 같은 진행화면을 확인할 수 있다.

.........................................................................................................................................................................................................................................................................

C:\> expdp scott/tiger tables=EMPLOYEES directory=DPDATA1 dumpfile=expEMPLOYEES.dmp job_name=EMPLOYEES_EXPORT

Export: Release 10.2.0.1.0 - Production on 수요일, 27 8월, 2008 23:17:17

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

접속 대상: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options
"SCOTT"."EMPLOYEES_EXPORT" 시작 중: scott/******** tables=EMPLOYEES directory=DP
DATA1 dumpfile=expEMPLOYEES.dmp job_name=EMPLOYEES_EXPORT
BLOCKS 메소드를 사용하여 예측 진행 중...
객체 유형 TABLE_EXPORT/TABLE/TABLE_DATA 처리 중
BLOCKS 메소드를 사용한 총 예측: 64 KB
객체 유형 TABLE_EXPORT/TABLE/TABLE 처리 중
객체 유형 TABLE_EXPORT/TABLE/TRIGGER 처리 중
객체 유형 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS 처리 중
. . "SCOTT"."EMPLOYEES"                         7.789 KB      13행이 엑스포트됨
마스터 테이블 "SCOTT"."EMPLOYEES_EXPORT"이(가) 성공적으로 로드됨/로드 취소됨
******************************************************************************
SCOTT.EMPLOYEES_EXPORT에 대해 설정된 덤프 파일:
  C:\DPDATA1\EXPEMPLOYEES.DMP
"SCOTT"."EMPLOYEES_EXPORT" 작업이 23:17:34에서 성공적으로 완료됨

.........................................................................................................................................................................................................................................................................

--IMPDP를 이용한 Import 예

--커맨드 프롬프트에서 다음과 같이 명령하여 앞에서 생성된 EXPEMPLOYEES.DMP 파일을 로드한다.
impdp scott/tiger directory=DPDATA1 dumpfile=EXPEMPLOYEES.DMP job_name=employees_import

--위의 명령결과 다음과 같은 진행화면을 볼 수 있다.

C:\>impdp scott/tiger directory=DPDATA1 dumpfile=EXPEMPLOYEES.DMP job_name=employees_import

Import: Release 10.2.0.1.0 - Production on 수요일, 27 8월, 2008 23:25:35

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

접속 대상: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
마스터 테이블 "SCOTT"."EMPLOYEES_IMPORT"이(가) 성공적으로 로드됨/로드 취소됨
"SCOTT"."EMPLOYEES_IMPORT" 시작 중: scott/******** directory=DPDATA1 dumpfile=EX
PEMPLOYEES.DMP job_name=employees_import
객체 유형 TABLE_EXPORT/TABLE/TABLE 처리 중
객체 유형 TABLE_EXPORT/TABLE/TABLE_DATA 처리 중
. . "SCOTT"."EMPLOYEES"                         7.789 KB      13행이 임포트됨
객체 유형 TABLE_EXPORT/TABLE/TRIGGER 처리 중
객체 유형 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS 처리 중
"SCOTT"."EMPLOYEES_IMPORT" 작업이 23:25:42에서 성공적으로 완료됨



이용자의 모든 테이블을 대상으로 한 경우
SQL> SHOW USER
USER은 "SYS"입니다
SQL> create directory dd as 'd:\';

디렉토리가 생성되었습니다.

SQL> grant write,read on directory dd to scott;

권한이 부여되었습니다.

SQL> exit
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options에서 분리되었습니다.

D:\>expdp scott/tiger directory=dd dumpfile=scott.dmp

Export: Release 10.2.0.1.0 - Production on 금요일, 11 1월, 2008 21:24:38

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

접속 대상: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Productio
n
With the Partitioning, OLAP and Data Mining options
"SCOTT"."SYS_EXPORT_SCHEMA_01" 시작 중: scott/******** directory=dd dumpfile=sco
tt.dmp
BLOCKS 메소드를 사용하여 예측 진행 중...
객체 유형 SCHEMA_EXPORT/TABLE/TABLE_DATA 처리 중
BLOCKS 메소드를 사용한 총 예측: 192 KB
객체 유형 SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/TABLE 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/INDEX/INDEX 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/COMMENT 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS 처리 중
. . "SCOTT"."DEPT"                              5.656 KB       4행이 엑스포트됨
. . "SCOTT"."EMP"                               7.820 KB      14행이 엑스포트됨
. . "SCOTT"."SALGRADE"                          5.585 KB       5행이 엑스포트됨
. . "SCOTT"."BONUS"                                 0 KB       0행이 엑스포트됨
마스터 테이블 "SCOTT"."SYS_EXPORT_SCHEMA_01"이(가) 성공적으로 로드됨/로드 취소됨

******************************************************************************
SCOTT.SYS_EXPORT_SCHEMA_01에 대해 설정된 덤프 파일:
  D:\SCOTT.DMP
"SCOTT"."SYS_EXPORT_SCHEMA_01" 작업이 21:24:51에서 성공적으로 완료됨


D:\>dir *.dmp
 D 드라이브의 볼륨: tmp
 볼륨 일련 번호: 4CF1-5633

 D:\ 디렉터리

2008-01-11  오후 09:24           221,184 SCOTT.DMP
               1개 파일             221,184 바이트
               0개 디렉터리  195,895,943,168 바이트 남음

D:\>sqlplus scott/tiger

SQL*Plus: Release 10.2.0.1.0 - Production on 금 1월 11 21:25:30 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


다음에 접속됨:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> drop table dept cascade constraint;

테이블이 삭제되었습니다.

SQL> drop table emp;

테이블이 삭제되었습니다.

SQL> drop table salgrade;

테이블이 삭제되었습니다.

SQL> drop table bonus;

테이블이 삭제되었습니다.

SQL> exit
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options에서 분리되었습니다.


D:\>impdp scott/tiger directory=dd dumpfile=scott.dmp

Import: Release 10.2.0.1.0 - Production on 금요일, 11 1월, 2008 21:28:18

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

접속 대상: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Productio
n
With the Partitioning, OLAP and Data Mining options
마스터 테이블 "SCOTT"."SYS_IMPORT_FULL_01"이(가) 성공적으로 로드됨/로드 취소됨
"SCOTT"."SYS_IMPORT_FULL_01" 시작 중: scott/******** directory=dd dumpfile=scott
.dmp
객체 유형 SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/TABLE 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/TABLE_DATA 처리 중
. . "SCOTT"."DEPT"                              5.656 KB       4행이 임포트됨
. . "SCOTT"."EMP"                               7.820 KB      14행이 임포트됨
. . "SCOTT"."SALGRADE"                          5.585 KB       5행이 임포트됨
. . "SCOTT"."BONUS"                                 0 KB       0행이 임포트됨
객체 유형 SCHEMA_EXPORT/TABLE/INDEX/INDEX 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT 처리 중
객체 유형 SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS 처리 중
"SCOTT"."SYS_IMPORT_FULL_01" 작업이 21:28:23에서 성공적으로 완료됨


D:\>