Oracle 數據庫導出數據泵(EXPDP)文件存放的位置


數據泵是服務器端工具,導出的文件是放在數據庫所在的服務器上,當然我們知道可以通過directory目錄對象來控制。目錄對象默認有四個級別,當然是有優先級順序的,優先級從上往下

1.每個文件單獨的指定具體的目錄

2.expdp導出時,指定的目錄參數

3.用戶定義的環境變量DATA_PUMP_DIR指定的目錄

4.默認的目錄對象DATA_PUMP_DIR 


當然了對於Oracle11g R2來說,又引入了一個可選項,我們就當是5

5.DATA_PUMP_DIR_SCHEMA_NAME目錄 

 

create or replace directory DATA_PUMP_DIR as 'D:\app\Administrator\admin\orcl\dpdump';  修改默認的DATA_PUMP_DIR路徑

一、默認的目錄對象DATA_PUMP_DIR測試

 

create or replace directory DATA_PUMP_DIR as 'D:\app\Administrator\admin\orcl\dpdump';    //改變默認DATA_PUMP_DIR位置


SQL>  desc dba_directories

 Name                                                              Null?    Type

 ----------------------------------------------------------------- -------- ---------------------- OWNER                                                            NOT NULL VARCHAR2(30)

 DIRECTORY_NAME                                                    NOT NULL VARCHAR2(30)

 DIRECTORY_PATH                                                            VARCHAR2(4000)

 


 

 


SQL> set linesize 120 pagesize 100

SQL> col OWNER for a5   

SQL> col DIRECTORY_NAME for a22

SQL> col DIRECTORY_PATH for a80

 

 

 

SQL> select * from dba_directories;

 


OWNER DIRECTORY_NAME        DIRECTORY_PATH

----- ---------------------- ----------------------------------------------------------

 


SYS  SUBDIR                /u01/app/oracle/product/11.2.0/db/demo/schema/order_entry//2002/Sep

SYS  SS_OE_XMLDIR          /u01/app/oracle/product/11.2.0/db/demo/schema/order_entry/

SYS  LOG_FILE_DIR          /u01/app/oracle/product/11.2.0/db/demo/schema/log/

SYS  MEDIA_DIR              /u01/app/oracle/product/11.2.0/db/demo/schema/product_media/

SYS  XMLDIR                /u01/app/oracle/product/11.2.0/db/rdbms/xml

SYS  DATA_FILE_DIR          /u01/app/oracle/product/11.2.0/db/demo/schema/sales_history/

SYS  DATA_PUMP_DIR          /u01/app/oracle/admin/tj01/dpdump/

SYS  ORACLE_OCM_CONFIG_DIR  /u01/app/oracle/product/11.2.0/db/ccr/state

 


 

 


通過查詢我們看到,所有的目錄都屬於SYS用戶,而不管是哪個用戶創建的,在數據庫里已經提前建好了這個目錄對象DATA_PUMP_DIR。如果在使用expdp導出時,不指定目錄對象參數,Oracle會使用數據庫缺省的目錄DATA_PUMP_DIR,不過如果想使用這個目錄的話,用戶需要具有exp_full_database的權限才行

 


 

 


SQL> conn scott/tiger

Connected.

 


SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID

------------------------------ ------- ----------

BONUS                          TABLE

DEPT                          TABLE

EMP                            TABLE

SALGRADE                      TABLE

 

 

 

SQL> create table demo as select empno,ename,sal,deptno from emp;

Table created.

 

 

 

SQL> exit         

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

 


 

 


由於沒有exp_full_database,所以這樣的導出會報錯,你可以選擇授權或者使用有權限的用戶

 


[oracle@asm11g ~]$ expdp scott/tiger dumpfile=emp.dmp tables=emp

Export: Release 11.2.0.3.0 - Production on Fri Nov 16 13:48:19 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

ORA-39002: invalid operation

ORA-39070: Unable to open the log file.

ORA-39145: directory object parameter must be specified and non-null

 

 

 

[oracle@asm11g ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Nov 16 13:58:14 2012

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

 


 

 


SQL> grant exp_full_database to scott;

Grant succeeded.

 


SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

 


 

 


授權之后,導出成功,並且導出的文件和日志會到DATA_PUMP_DIR對象指定的目錄

[oracle@asm11g ~]$ expdp scott/tiger dumpfile=emp.dmp tables=emp

 


Export: Release 11.2.0.3.0 - Production on Fri Nov 16 13:58:52 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

Starting "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** dumpfile=emp.dmp tables=emp

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported "SCOTT"."EMP"                              8.562 KB      14 rows

Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded

******************************************************************************

Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:

  /u01/app/oracle/admin/tj01/dpdump/emp.dmp

Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 13:59:05

 

 

 

對於oracle11g來說,我們還可以定義一個新的目錄對象,對象名稱是DATA_PUMP_DIR_SCHEMA_NAME,如果定義了這個目錄對象,並授予權限,在用戶導出沒有指定

 


具體的目錄參數的情況下,導出文件會到這個目錄

 


[oracle@asm11g ~]$ mkdir sdir

[oracle@asm11g ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Nov 16 14:13:06 2012

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

 


Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

 


 

 


SQL> create directory data_pump_dir_scott as '/home/oracle/sdir';

Directory created.

 


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

Grant succeeded.

 


SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

 


 

 


[oracle@asm11g ~]$ expdp scott/tiger dumpfile=emp1.dmp tables=emp

 


 

 


Export: Release 11.2.0.3.0 - Production on Fri Nov 16 14:14:29 2012

 


Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

Database Directory Object has defaulted to: "DATA_PUMP_DIR_SCOTT".

Starting "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** dumpfile=emp5.dmp tables=emp

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported "SCOTT"."EMP"                              8.562 KB      14 rows

Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded

******************************************************************************

Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:

  /home/oracle/sdir/emp1.dmp

Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 14:14:34

 

來自:https://www.linuxidc.com/Linux/2013-05/83774.htm


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM