How To Specify A Directory For Export Dump in Windows
How To Specify A Directory For Export Dump in Windows
How To Specify A Directory For Export Dump in Windows
Applies to:
Enterprise Manager for RDBMS - Version: 10.1 to 10.2
Oracle Server - Enterprise Edition - Version: 10.1 to 10.2
Oracle Server - Personal Edition - Version: 10.1 to 10.2
Oracle Server - Standard Edition - Version: 10.1 to 10.2
Information in this document applies to any platform.
Goal
This document describes how a directory can be specified that is used by the Oracle10g
Export/Import DataPump utilities to write the dumpfile(s), logfile (if specified) and SQL file (if
specified).
The document is meant for everyone who uses the Export DataPump (expdp) utility to export data
from an Oracle10g or higher database and the Import DataPump (impdp) utility to import data into an
Oracle10g or higher release database.
Solution
1. Server-Based versus Client-Based.
The parameter DIRECTORY specifies the location to which Export DataPump or Import DataPump
can write the dump file set, the log file, and the SQL file (Import DataPump only).
As export DataPump and import DataPump are server-based, rather than client-based, the output
files are accessed relative to server-based directory paths. Data Pump requires you to specify
directory paths as directory objects. A directory object maps a name to a directory path on the file
system.
To create a directory, you must have the DBA role or you must have been granted the CREATE ANY
DIRECTORY privilege.
Example (a DBA creates directories on the Windows platform and grants access to user scott):
CONNECT system/manager
CREATE OR REPLACE DIRECTORY my_dir as 'D:\DataPump';
CREATE OR REPLACE DIRECTORY my_logdir as 'E:\logs';
GRANT read, write ON DIRECTORY my_dir TO scott;
GRANT read, write ON DIRECTORY my_logdir TO scott;
Example (a normal user with the CREATE ANY DIRECTORY privilege creates directories on the Unix
platform - this user automatically has READ and WRITE privilege on that directory):
CONNECT system/manager
GRANT CREATE ANY DIRECTORY TO scott;
CONNECT scott/tiger
CREATE OR REPLACE DIRECTORY my_dir as '/usr/DataPump';
CREATE OR REPLACE DIRECTORY my_logdir as '/usr/logs';
Note that the CREATE DIRECTORY statement does not actually create the directory for you on disk.
If the directory is invalid, a DataPump job will fail with:
SET lines 80
COL grantee FORMAT a20
COL privilege FORMAT a10
SELECT directory_name, grantee, privilege
FROM user_tab_privs t, all_directories d
WHERE t.table_name(+)=d.directory_name
ORDER BY 1,2,3;
Note that READ or WRITE permission to a directory object only means that the Oracle database will
read or write that file on your behalf. You are not given direct access to those files outside of the
Oracle database unless you have the appropriate operating system privileges. Similarly, the Oracle
database requires permission from the operating system to read and write files in the directories.
5.1. If a directory object is specified as part of the file specification, then the location specified by that
directory object is used. Example to create the dumpfile in directory MY_DIR (no logfile is written):
5.3. If a directory object is not specified, and if no directory object was named by the DIRECTORY
parameter, then the value of the environment variable, DATA_PUMP_DIR, is used. This environment
variable is defined using operating system commands on the client system where the Data Pump
Export and Import utilities are run. The value assigned to this client-based environment variable must
be the name of a server-based directory object, which must first be created on the server system.
Example to create the dump file in directory MY_DIR and the logfile in MY_DIR_LOG:
On the client machine where expdp is started, set the environment variable:
Note that the interpretation of the name of the directory in the environment variable
DATA_PUMP_DIR is case sensitive. Specifying an incorrect value for the DATA_PUMP_DIR
environment variable (e.g.: set DATA_PUMP_DIR=My_Dir) can give errors, such as:
5.4. If none of the previous three conditions yields a directory object and you are a privileged user
(i.e. uses who have the EXP_FULL_DATABASE role and IMP_FULL_DATABASE role), then Data
Pump attempts to use the value of the default server-based directory object, DATA_PUMP_DIR.
It is important to understand that Data Pump does not create the DATA_PUMP_DIR directory object;
it merely attempts to use its value when a privileged user has not provided a directory object using
any of the mechanisms previously described. This default directory object must first be created by a
DBA. Do not confuse this with the client-based environment variable of the same name.
Example to create all files in the directory DATA_PUMP_DIR:
First unset the environment variable DATA_PUMP_DIR that was set in the previous example:
CONNECT SYSTEM/MANAGER
CREATE OR REPLACE DIRECTORY data_pump_dir AS 'D:\DataPump';
GRANT read, write ON DIRECTORY data_pump_dir TO scott;
Solution for user SCOTT: as described in 5.3. user SCOTT can set the environment variable
DATA_PUMP_DIR to MY_DIR:
Or in this specific case where user SCOTT also has the read and write privilege on directory
DATA_PUMP_DIR:
: RAC CONSIDERATION
Make sure that log on to primary node where the data pump directory is located