Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Data pump takes the old export and import one step further, you can have total control over the job running
(stop it, pause it, check it, restart it). Data pump is a server side technology and it can transfer large amounts of
data very quickly, using parallel streams to achieve maximum throughput, they can be 15-45% faster than the
older import/export utilities. Advantages using data pump are
A couple of notes is that you cannot export to a tape device only to disk, and the import will only work with
version of oracle 10.1 or greater.
• migrating databases
• copying databases
• transferring oracle databases between different operating systems
• backing up important tables before you change them
• moving database objects from one tablespace to another
• transporting tablespace's between databases
• reorganizing fragmented table data
• extracting the DDL for tables and other objects such as stored procedures and packages
• dbms_datapump - the main engine for driving data dictionary metadata loading and unloading
• dbms_metadata - used to extract the appropriate metadata
• command-line - expdp and impdp are the import/export equivalents
Data pump has two methods for loading data, direct path or external table path you as a dba have no control
with data pump uses, normally simple structures such as heap tables without triggers will use direct path more
complex tables will use the external path, oracle will always try and use the direct-path method.
bypasses the database buffer cache and writes beyond the high water mark when finished adjusts the
Direct Path high water mark No undo is generated and can switch off redo as well, minimal impact to users as does
not use SGA. Must disable triggers on tables before use.
External Uses the database buffer cache acts as a SELECT statement into a dump file, during import reconstructs
Data Pump Export and Import
statements into INSERT statements, so whole process is like a normal SELECT/INSERT job. Both
Path
undo and redo are generated and uses a normal COMMIT just like a DML statement would.
• clustered tables
• active triggers in the table
• a single partition in a table with a global index
• referential integrity constraints
• domain indexes on LOB columns
• tables with fine-grained access control enabled in the insert mode
• tables with BFILE or opaque type columns
You will use three typess of files when using data pump, all files will be creted on the server.
In order to advance features of data pump you need exp_full_database and imp_full_database privilgeges.
The Master Control Process (MCP), has the process name DMnn, only one master job runs per job which
controls the whole Data Pump job, it performs the following
The master process creates a master table which contains job details (state, restart info), this table is created in
the users schema who is running the Data Pump job. Once the job has finished it dumps the table contents into
the data pump file and deletes the table. When you import the data pump file it re-creates the table and read it to
verify the correct sequence in which the it should import the various database objects.
The worker process is named DWnn and is the process that actually performs the work, you can have a number
of worker process running on the same job (parallelism). The work process updates the master table with the
various job status.
The shadow process is created when the client logs in to the oracle server it services data pump API requests, it
creates the job consisting of the master table and the master process.
Data Pump Export and Import
You can either run via a commandline specifying options or use a parameter file, there are many options to Data
Pump so it would be best to check out the oracle web site, I have given a few examples below
Exporting
# expdp vallep/password directory=datapump full=y dumpfile=data.dmp
filesize=2G parallel=2 logfile=full.log
database
Note: increase the parallel option based on the number of CPU's you have
schema # expdp sys/password schemas=testuser dumpfile=data.dmp logfile=schema.log
# expdp vallep/password tables=accounts,employees dumpfile=data.dmp
table
content=metadata_only
# expdp vallep/password tablespaces=users dumpfile=data.dmp
tablespace
logfile=tablespace.log
Importing
database # impdp system/password full=y dumpfile=data.dmp nologfile=y
# impdp system/password schemas=’HR’ remap_schema=’HR:HR_TEST’
content=data_only
schema change
# impdp system/passwd remap_schema=’TEST:TEST3’ tables=test log=…
dumpfile=… directory=…
Other Options
directory specifies a oracle directory object
filesize split the dump file into specific sizes (could be used if filesystem has 2GB limit)
parfile specify the parameter file
compression compression is used by default but you can stop it
exclude/include metadata filtering
query selectively export table data usin a SQL statement
estimate tells you how much space is required without running the job
network link you can perform a export across a network
encryption you can encrypt data within the data pump file
parallel increase worker processes to increase throughput, base it on number of CPU's
remap_schema move objects from one schema to another
remap_datafile change the name of the datafile when moving across different systems
remap_tablespace move from one tablespace to another
Useful Tables
DBA_DATAPUMP_JOBS summary information of all currently running data pump jobs
DBA_DATAPUMP_SESSIONS displays the user currently running data pump jobs
V$SESSION_LONGOPS display information like totalwork, sofar, units and opname
Data Pump Export and Import
Privileges
IMP_FULL_DATABASE required if using advanced features
EXP_FULL_DATABASE required if using advanced features
DBMS_DATAPUMP package
• starting/stopping/restarting a job
• monitoring a job
• detaching from a job
declare
d1 number;
begin
d1 := dbms_datapump.open('export','schema',null, 'test1', 'latest');
exporting dbms_datapump.add_file(d1, 'test1.dmp', 'dmpdir');
dbms_datapump.metadata_filter(d1, 'schema_expr','in (''OE'')');
dbms_datapump.start_job(d1);
dbms_datadump.detach(d1);
end;
declare
d1 number;
begin
d1 := dbms_datapump.open('import','full',null, 'test1');
importing dbms_datapump.add_file(d1, 'test1.dmp', 'dmpdir');
dbms_datapump.metadata_remap(d1, 'remap_schema', 'oe', 'hr');
dbms_datapump.start_job(d1);
dbms_datadump.detach(d1);
end;