Oracle 10g 및 이후 내 보 내기/가 져 오기(Datapump Export/Import)도구

16683 단어 Oacle직장레저
http://www.orafaq.com/wiki/Data_Pump
혹시
http://www.orafaq.com/wiki/Datapump
 
 Datapump 는 대 용량 데이터 이전 구 조 를 바탕 으로 오래된 import/export 도 구 를 대체 하 는 서비스 입 니 다.오래된 import/export 도 구 는 여전히 사용 할 수 있 지만 모든 Oracle 10g 과 11g 의 기능 은 지원 되 지 않 습 니 다.이 새 도구 의 이름 은 expdp 와 impdp 입 니 다.
본문 내용
본 고 는 Oracle 10g 및 그 후 버 전 내 보 내기/입 도구 의 절 차 를 소개 합 니 다.내용 은 다음 과 같 습 니 다.
datapump 내 보 내기 시작데이터베이스 디 렉 터 리 만 들 기
  • 다시 내 보 내기 시도
  • 다른 데이터 베 이 스 를 가 져 옵 니 다.
    네트워크 도입
    PL/SQL 에서 호출내 보 내기/입력 설명
    더참고 자료
     
    datapump 로 내 보 내기 시작
    
    $ expdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp
    
     
    
    Export: Release 10.2.0.1.0 - 64bit Production on Friday, 31 March,  2006 11:36:07
    
    Copyright (c) 2003, 2005, Oracle.  All rights reserved.
    
     
    
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    
     
    
    ORA-39002: invalid operation
    
    ORA-39070: Unable to open the log file.
    
    ORA-39087: directory name DMPDIR is invalid

    설명:
  • "dmpdir"는 디 렉 터 리 내 보 내기 입 니 다
  • "scott.dmp"가 내 보 내기 위 한 datadump 파일;
  • scott 사용자 의 시 계 는 기본 표 공간 USERS 와 임시 표 공간 TEMP 에 있 습 니 다.그래서 이 명령 은 scott 사용 자 를 자신의 시계(대상)로 유도 합 니 다
  • Oracle 은 이미 이 두 개의 표 공간 이 있 기 때문에 직접 가 져 오 면 된다.단,자신 이 만 든 시계 공간 이 라면 이 시계 공간 을 만 든 다음 가 져 와 야 합 니 다

  • 내 보 내기 실패!디 렉 터 리 를 먼저 만들어 야 하기 때 문 입 니 다!
     
    데이터베이스 디 렉 터 리 만 들 기
    다음 명령 을 실행 하여 데이터베이스 내 보 내기 디 렉 터 리 를 만 듭 니 다.이 디 렉 터 리 는 같은 서버 의 유효한 디 렉 터 리 를 데이터베이스 로 가 리 켜 야 합 니 다.
    SQL> CREATE DIRECTORY dmpdir AS '/opt/oracle';
    
    Directory created.
    
     
    SQL> GRANT read, write ON DIRECTORY dmpdir TO scott;
    Grant succeeded.

    설명:
  • "dmpdir"는 디 렉 터 리 내 보 내기,"/opt/oracle"은 데이터베이스 경로("d:\db 와 같은 시스템 의 절대 경로 도 조작 할 수 있 습 니 다.backup");

  • 디 렉 터 리 내 보 내기 권한 부여scott 사용자 가 이 디 렉 터 리 를 읽 고 쓸 수 있 도록 합 니 다.이렇게 해야만 scott 사용자 가 이 디 렉 터 리 에 정상적으로 접근 하여 데이터베이스 내용 과 내 보 낸 로그 파일 을 여기에 놓 을 수 있 습 니 다
    비고:Oracle 은 Oracle 10g R2 부터'DATA'라 는 이름 을 도입 했다.PUMP_DIR"의 기본 디 렉 터 리 는 다음 과 같 습 니 다.
    SQL> SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';
    
     
    
    DIRECTORY_PATH
    
    --------------------------------------------------------------------------------
    
    /app/oracle/product/10.2.0/rdbms/log/

     
    다시 내 보 내기 시도
    
    $ expdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp
    
     
    
    Export: Release 10.2.0.1.0 - 64bit Production on Friday, 31 March, 2006 11:41:02
    
    Copyright (c) 2003, 2005, Oracle.  All rights reserved.
    
     
    
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    
    Starting "SCOTT"."SYS_EXPORT_SCHEMA_01":  scott/********  DIRECTORY=dmpdir DUMPFILE=scott.dmp
    
    Estimate in progress using BLOCKS method...
    
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    
    Total estimation using BLOCKS method: 175.2 MB
    
    Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
    
    Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
    
    Processing object type SCHEMA_EXPORT/TABLE/TABLE
    
    Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
    
    Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
    
    Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    
    Processing object type SCHEMA_EXPORT/TABLE/COMMENT
    
    Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
    
    Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
    
    Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
    
    Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
    
    Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
    
    Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
    
    Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    
    Processing object type SCHEMA_EXPORT/JOB
    
    . . exported "SCOTT"."BIGEMP"                            145.2 MB 3670016 rows
    
    . . exported "SCOTT"."DEPT"                              5.656 KB       4 rows
    
    . . exported "SCOTT"."EMP"                               7.820 KB      14 rows
    
    . . exported "SCOTT"."ORD_CHARGE_TAB"                    5.296 KB       2 rows
    
    . . exported "SCOTT"."SALGRADE"                          5.585 KB       5 rows
    
    . . exported "SCOTT"."BONUS"                                 0 KB       0 rows
    
    . . exported "SCOTT"."NEWOBJECT1_T"                          0 KB       0 rows
    
    . . exported "SCOTT"."T1"                                    0 KB       0 rows
    
    Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
    
    ******************************************************************************
    Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
    
      /app/oracle/scott.dmp
    
    Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 11:44:50

     
    다른 데이터베이스 로 가 져 오기
    
    $ impdp system/oracle DIRECTORY=dmpdir DUMPFILE=scott.dmp
    
     
    
    Import: Release 10.2.0.1.0 - 64bit Production on Friday, 31 March, 2006 12:00:59
    
    Copyright (c) 2003, 2005, Oracle.  All rights reserved.
    
     
    
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    
    Master table "SYSTEM"."SYS_IMPORT_FULL_02" successfully loaded/unloaded
    
    Starting "SYSTEM"."SYS_IMPORT_FULL_02":  system/******** DIRECTORY=dmpdir DUMPFILE=scott.dmp
    
    Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
    
    Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
    
    Processing object type SCHEMA_EXPORT/TABLE/TABLE
    
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    
    . . imported "SCOTT"."BIGEMP"                            145.2 MB 3670016 rows
    
    . . imported "SCOTT"."DEPT"                              5.656 KB       4 rows
    
    . . imported "SCOTT"."EMP"                               7.820 KB      14 rows
    
    . . imported "SCOTT"."ORD_CHARGE_TAB"                    5.296 KB       2 rows
    
    . . imported "SCOTT"."SALGRADE"                          5.585 KB       5 rows
    
    . . imported "SCOTT"."BONUS"                                 0 KB       0 rows
    
    . . imported "SCOTT"."NEWOBJECT1_T"                          0 KB       0 rows
    
    . . imported "SCOTT"."T1"                                    0 KB       0 rows
    
    Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
    
    Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
    
    Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    
    Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
    
    Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
    
    Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
    
    Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
    
    Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
    
    Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
    
    Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    
    Processing object type SCHEMA_EXPORT/JOB
    
    Job "SYSTEM"."SYS_IMPORT_FULL_02" successfully completed at 12:02:22

     
    비고:
  • expdp 와 impdp 명령 은 모두 운영 체제 에서 실 행 됩 니 다
  • 내 보 내기 디 렉 터 리 를 만 들 고 권한 을 부여 합 니 다.모두 SQL PLUS 에서 실 행 됩 니 다

  •  
    네트워크 가 져 오기
    네트워크 모드 를 통 해 가 져 옵 니 다.중간 에 있 는 dump 파일 이 필요 없습니다.데 이 터 는 데이터베이스 링크(database link)를 통 해 내 보 내 고 대상 데이터 베 이 스 를 직접 가 져 옵 니 다.예 를 들 면:
    SQL> create user new_scott identified by tiger;
    User created.
    
     
    SQL> grant connect, resource to new_scott;
    Grant succeeded.
    
     
    SQL> grant read, write on directory dmpdir to new_scott;
    Grant succeeded.
    
     
    SQL> grant create database link to new_scott;
    Grant succeeded.

     
    SQL> conn new_Scott/tiger
    
    Connected.
    
     
    SQL> create database link old_scott connect to scott identified by tiger  using 'orcl.oracle.com';
    Database link created.

     
    
    $ impdp new_scott/tiger DIRECTORY=dmpdir NETWORK_LINK=old_scott remap_schema=scott:new_scott

    모든 작업 은 목표 운영 체제 에서 이 루어 진다.원본 운영 체제 에 대한 유일한 인용 은 데이터베이스 링크(database link)를 통 해 이 루어 집 니 다.
     
    PL/SQL 에서 호출
    PL/SQL 에서 datapump 를 호출 할 수 있 습 니 다.이것 은 매일 또는 매주 DBMS 를 사용 할 계획 입 니 다.SCHEDULER 내 보 내기 가 편리 합 니 다.
    DECLARE
    
      hand NUMBER;
    BEGIN
    
      hand := Dbms_DataPump.Open(operation => 'EXPORT',
    
                                  job_mode => 'FULL',
    
                                  job_name => 'FULLEXPJOB',
    
                                   version => 'COMPATIBLE');
    
      Dbms_DataPump.Add_File(handle => hand,
    
                           filename => 'expdp_plsql.log',
    
                          directory => 'DMPDIR',
    
                           filetype => 3);
    
      Dbms_DataPump.Add_File(handle => hand,
    
                           filename => 'expdp_plsql.dmp',
    
                          directory => 'DMPDIR',
    
                           filetype => 1);
    
      -- Dbms_DataPump.Set_Parameter(handle => hand,
    
      --                               name => 'ESTIMATE',
    
      --                              value => 'STATISTICS');
    
      Dbms_DataPump.Start_Job(hand);
    END;
    
    /

     
    내 보 내기/입력 설명
    일반적인 상황 에서 내 보 내기/입력 은 많은 문제 가 발생 하지 않 습 니 다.몇 가지 만 주의 하면 됩 니 다.
  • 디 렉 터 리 내 보 내기 가 존재 해 야 합 니 다.그렇지 않 으 면 내 보 내기 도구 가 export.log 내 보 내기 파일 로 그 를 쓸 수 없습니다.Ora 오류 가 발생 합 니 다

  • 내 보 내기 에 사용 할 사용 자 는 내 보 내기 디 렉 터 리 에 읽 기와 쓰기 권한 이 있어 야 합 니 다.이것 은 명백히 알 수 있다
    4.567917.가 져 올 때 해당 하 는 표 공간 과 사용 자 는 반드시 존재 해 야 합 니 다.이것 도 뻔 해.
    이 세 가 지 를 주의 하 세 요.일반적으로 내 보 내기/들 어 오 는 데 성공 합 니 다.
     
    훨씬
    이상 의 예 는 처음 시작 한 너 에 게 이미 충분 하 다.더 많은 정 보 는 Oracle 도구 안내 서 를 참조 하 십시오.다음 명령 을 입력 하면 이 명령 의 모든 인 자 를 표시 할 수 있 습 니 다.
    
    $ expdp help=yes
    
    $ impdp help=yes

     
    이상 은 Oracle FAQ 가 제시 한 가 져 오기/꺼 내기 도구 의 예제 입 니 다.
    잠시 후,내 기계 에서 시범 을 보 여 준다.
     
    참고 자료
    Oracle 10g 이전 내 보 내기/입력 도구http://www.orafaq.com/wiki/Import_Export_FAQ
    Oracle 도구http://www.orafaq.com/wiki/Category:Utilities
     
     
    다음으로 이동:http://www.cnblogs.com/liuning8023/archive/2012/03/29/2424435.html

    좋은 웹페이지 즐겨찾기