Difference Between ORACLE Export (exp/imp) and Datapump (expdp/impdp)


ORACLE provides two inbuild utilities to transfer database objects from one database to another database or same database. Traditional exports (exp /imp) are introduced before 10g.From 10g, ORACLE introduced datapump (expdp / impdp) as an enhancement to traditional export utility.
Below some difference between datapump and Export/Import.
  • =>Datapump is a server side utility whereas export/import is a client side utility. Conventional exp/imp can utilize the client machine resource for taking the backups but, the datapump works only in server.
  • => Dtapump extracting database from block wise but normal export extracting data as select * from. For this only database pump is very faster.
  • => Datapump operates on a group of files called dump file sets. However, normal export operates on a single file.
  • => Datapump access files in the server (using directories). Traditional export can access files in client and server both (using on machine current path).
  • => Exports (exp/imp) represent database metadata information as DDLs in the dump file, but in datapump, it represents in XML document format.
  • => Datapump has parallel execution but in exp/imp single stream execution.
  • => Datapump does not support sequential media like tapes, but traditional export supports.
  • => In Data Pump, we can stop and restart the jobs.
  • => Data Pump will recreate the user, whereas the old imp utility required the DBA to create the user ID before importing.
  • => Data Pump gives you the ability to pass data between two databases over a network (via a database link), without creating a dump file on disk. 
  • => Datapump uses the Direct Path data access method (which permits the server to bypass SQL and go right to the data blocks on disk) has been rewritten to be much more efficient and now supports Data Pump Import and Export.
Below Some examples of Datapump and export/Import:
Full Database export:                                            
=>exp userid=system/Password@tns file=export.dmp log=export.log full=y statistics=none
Note: statistics=none, means  you will not export/import this information which will make it go faster and will result in a smaller dumpfile. You can re-calculate these statistics when your import is finished by using the dbms_stats package.

Full Database import:
> imp userid=system/Password@tns file=export.dmp log=import.log full=y statistics=none

Full Database EXPDP:
=> EXPDP userid=system/Password@tns dumpfile=export.dmp logfile=export.log full=y exclude=statistics directory=dp_dir
=> IMPDP userid=system/Password@tns dumpfile=export.dmp logfile=import.log full=y exclude=statistics directory=dp_dir

How to Create Directory and what is used for:

Use the CREATE DIRECTORY statement to create a directory object. A directory object specifies an alias for a directory on the server file system where external binary file LOBs (BFILEs) and external table data are located. You can use directory names when referring to BFILEs in your PL/SQL code and OCI calls, rather than hard coding the operating system path name, for management flexibility.
All directories are created in a single namespace and are not owned by an individual schema. You can secure access to the BFILEs stored within the directory structure by granting object privileges on the directories to specific users.
When you create a directory, you are automatically granted the READ and WRITE object privileges on the directory, and you can grant these privileges to other users and roles. The DBA can also grant these privileges to other users and roles.
Syntax:
CREATE DIRECTORY DP_DIR AS '/scratch/file_data';
For granting respective user:
Grant read, write on directory DP_DIR to user_name;

Table Exports/Imports:
The TABLES parameter is used to specify the tables that are to be exported.
expdp username/password@tns  tables=EMP,DEPT directory=DP_DIR dumpfile=EXP_EMP_DEPT.dmp logfile=exp_EMP_DEPT.log
impdp username/password@tns  tables=EMP,DEPT directory=DP_DIR dumpfile=EXP_EMP_DEPT.dmp logfile=imp_EMP_DEPT.log

Schema Exports/Imports:
The OWNER parameter of exp has been replaced by the SCHEMAS parameter which is used to specify the schemas to be exported.
expdp username/password@tns  schemas=USERNAME directory=DP_DIR dumpfile=EXP_USERNAME.dmp logfile=exp_USERNAME.log
impdp username/password@tns schemas=USERNAME directory=DP_DIR dumpfile=EXP_USERNAME.dmp logfile=imp_USERNAME.log

No comments:

Post a Comment

thedbaportfolio@gmail.com