Because Data Pump is server-based, rather than client-based, dump files, log files, and SQL 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.
For example, the following SQL statement creates a directory object named dpump_dir1
that is mapped to a directory located at /usr/apps/datafiles.
SQL> CREATE DIRECTORY dpump_dir1 AS '/usr/apps/datafiles';
The reason that a directory object is required is to ensure data security and integrity. For example:
-
If you were allowed to specify a directory path location for an input file, you might be able to read data that the server has access to, but to which you should not.
-
If you were allowed to specify a directory path location for an output file, the server might overwrite a file that you might not normally have privileges to delete.
Before you can run Data Pump Export or Data Pump Import, a directory object must be created by a database administrator (DBA) or by any user with the CREATE
ANY
DIRECTORY
privilege. Then, when you are using Export or Import, you specify the directory object with the DIRECTORY
parameter.
After a directory is created, the user creating the directory object needs to grant READ
or WRITE
permission on the directory to other users. For example, to allow the Oracle database to read and write files on behalf of user hr
in the directory named by dpump_dir1
, the DBA must execute the following command:
SQL> GRANT READ, WRITE ON DIRECTORY dpump_dir1 TO hr;
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.
Data Pump Export and Import use the following order of precedence to determine a file's location:
-
If a directory object is specified as part of the file specification, then the location specified by that directory object is used. (The directory object must be separated from the filename by a colon.)
-
If a directory object is not specified for a file, then the directory object named by the
DIRECTORY
parameter is used. -
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 by a DBA. For example, the following SQL statement creates a directory object on the server system. The name of the directory object isDUMP_FILES1
, and it is located at'/usr/apps/dumpfiles1'
.SQL> CREATE DIRECTORY DUMP_FILES1 AS '/usr/apps/dumpfiles1';
Then, a user on a UNIX-based client system using
csh
can assign the valueDUMP_FILES1
to the environment variableDATA_PUMP_DIR
. TheDIRECTORY
parameter can then be omitted from the command line. The dump fileemployees.dmp
, as well as the log fileexport.log
, will be written to'/usr/apps/dumpfiles1'
.%setenv DATA_PUMP_DIR DUMP_FILES1
%expdp hr/hr TABLES=employees DUMPFILE=employees.dmp -
If none of the previous three conditions yields a directory object and you are a privileged user, 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 theDATA_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.
No comments:
Post a Comment