Introduction
Oracle's export utility allows
you to extract data from the database and write that data to the operating
system file. The file to which you extract data when you use Oracle8i’s export
utility is referred to as a dump file. Exports dump file contains both metadata
and data. Metadata refers to the Data Definition Language (DDL) statements
necessary to recreate the objects that have been exported.
To
migrate data between oracle databases, within oracle databases, different
tablespaces, to change ownership of objects, Oracle has provided with utilities
called Exports and Imports. Exports and Imports are mainly used for data reorganization, which leads to
greater performance. Exports and imports are also used as a logical backup
tool.
New features in oracle 8i enable us to migrate data between different
tablespaces. This utility is used to migrate data between higher versions,
releases of Oracle used for repeating test runs (large sample data) for
development environment, moving data from testing to development. Also used to
archive large historical data, migrating data from one O/S platform to another
O/S platform.
Some of the important uses of the export
utility include the following:
- Copying tables or entire schemas, from one database to another.
- Reorganizing a table by exporting the data, recreating the table
with different storage parameters, and reloading the data-all in the same
database.
- Storing data as secondary backup
- Creating a logical backup that you can use to restore specific
tables rather than the entire database.
- Creating the temporary backup of objects that you are going to
delete.
The various operations that are to be known in
order to use effectively are:
- Starting the export utility
- Passing parameters to it
- Running it interactively
- Getting help when you need it
- Using its prerequisites
Using Export prerequisites
To use the Export utility, a user must have the
CREATE SESSION privilege on the target database. That’s all you need as long as
you are executing objects that you own. To export tables owned by another user
or to export the entire database, you must have the EXP_FULL_DATABASE role, and
you must have it enabled. Typically, you will have the DBA role, which includes
the EXP_FULL_DATABASE role, so you can export pretty much anything that you
want to export.
Before using Export against a database, you must
run the CATEXP.SQL script once to create views and tables that the Export
utility requires. The EXP_FULL_DATABASE role is one of the items that
CATEXP.SQL creates. The CATEXP.SQL script is run by CATALOG.SQL, so if you ran
CATALOG.SQL when you first created the database, you are all set. If you find
that you do need to run either of these scripts, you’ll find them in the $ORACLE_HOME/RDBMS/ADMIN directory.
Create Directory
CONN SYS AS SYSDBA
SQL> CREATE OR REPLACE DIRECTORY EXPORTDR AS ‘E:\AXPDUMP’;
SQL> GRANT READ, WRITE ON DIRECTORY EXPORTDR TO CORPORATE;
Schema Export and Import
- Below is syntax for export & import individual Schema.
expdp system/admin@orcl schemas=CORPORATE directory=EXPORTDR dumpfile=CORPORATE.DMP logfile=corporate.log
impdp system/admin@orcl schemas=CORPORATE directory=EXPORTDR dumpfile=CORPORATE.DMP logfile=corporate.log
Tables Export and Import
- Below is syntax for export & import individual tables.
expdp corporate/corporate@orcl tables=stockvalue,saleinvoices directory=EXPORTDR dumpfile=stockvaluesaleinvoices.dmp logfile=stockvaluesaleinvoices.log
impdp corporate/corporate@orcl tables=stockvalue,saleinvoices directory=EXPORTDR dumpfile=stockvaluesaleinvoices.dmp logfile=stockvaluesaleinvoices.log
Table Export and Import From Full Backup With include and exclude
- The INCLUDE and EXCLUDE parameters can be used to limit the export/import to specific objects. When the INCLUDE parameter is used, only those objects specified by it will be included in the export/import. When the EXCLUDE parameter is used, all objects except those specified by it will be included in the export/import.
impdp SYSTEM/admin@db schemas=CORPORATE include=TABLE:"IN ('STOCKVALUE', 'SALESINVOICE')" directory=EXPORTDR dumpfile=backupdumpfilename.dmp logfile=logfilenameforimp.log
impdp SYSTEM/admin@db schemas=CORPORATE exclude=TABLE:"= 'EMPLOYEE'" directory=EXPORTDR dumpfile=CORPORATE.dmp logfile=CORPORATE.log
Full Database Export and Import
- Below is syntax for export & import Full Database.
expdp system/admin@orcl full=y directory=EXPORTDR dumpfile=fulldatabase.dmp logfile=fulldatabase.log
impdp system/admin@orcl full=y directory=EXPORTDR dumpfile=fulldatabase.dmp logfile=fulldatabase.log
Database Export and Import with Network_Link
Below are steps for Import & Export with Network_Link.Make sure network should be available till finish the Job.
SQL> create public database link "DEV" connect to SYSTEM
identified by "admin"
using 'DEV'
Database link created.
Import with Network_Link
impdp system/admin@test LOGFILE=15102013_2120-system.txt NETWORK_LINK=DEV schemas=CORPORATE directory=DATA_PUMP_DIR
;;;
Import: Release 11.2.0.3.0 - Production on Tue Oct 15 21:20:05 2013
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, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01": system/********@test LOGFILE=15102013_2120-system.txt NETWORK_LINK=PROD schemas=CORPORATE directory=DATA_PUMP_DIR
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 46.12 GB
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"CORPORATE" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Processing object type SCHEMA_EXPORT/DB_LINK
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . imported "CORPORATE"."MVW_SALESREGISTER" 21857513 rows
. . imported "CORPORATE"."STOCKVALUE" 29229785 rows
. . imported "CORPORATE"."MVW_COSTOFGOODS_V2" 27764400 rows
. . imported "CORPORATE"."SALESINVOICEHDR" 12856752 rows
. . imported "CORPORATE"."SALESINVOICEDTL" 27722234 rows
. . imported "CORPORATE"."TB_COSTOFGOODS2_2011" 5650656 rows
. . imported "CORPORATE"."MVW_COSTOFGOODS_V3" 12301907 rows
. . imported "CORPORATE"."TB_COSTOFGOODS2_2012" 12301893 rows
. . imported "CORPORATE"."STOCKBATCHVALUE_V2" 15365374 rows
. . imported "CORPORATE"."MVW_STOCKBATCHVALUE_2012" 12248286 rows
. . imported "CORPORATE"."STOCKBATCHVALUE_2012" 12248288 rows
. . imported "CORPORATE"."SALESSUMMARY" 5050365 rows
. . imported "CORPORATE"."STOCKBATCHVALUE" 9779245 rows
. . imported "CORPORATE"."MVW_STOCKBATCHVALUE" 9779245 rows
. . imported "CORPORATE"."SALESCLOSINGDTL" 12207626 rows
. . imported "CORPORATE"."STOCKBATCHVALUE_V2_2011" 5596522 rows
. . imported "CORPORATE"."RECVPKTS" 1991476 rows
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/MATERIALIZED_VIEW
Processing object type SCHEMA_EXPORT/JOB
Processing object type SCHEMA_EXPORT/REFRESH_GROUP
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 0 error(s) at 00:31:12
Export with Network_Link
expdp system/admin@test LOGFILE=15102013_2120-system.txt NETWORK_LINK=DEVschemas=CORPORATE directory=DATA_PUMP_DIR
;;;
Export: Release 11.2.0.3.0 - Production on Thu Feb 6 20:00:01 2014
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, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01": SYSTEM/********@TEST version=11.1.0 directory=DATA_PUMP_DIR dumpfile=06022014_2000-CORPORATE.dmp logfile=06022014_2000-CORPORATE.txt
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 39.61 GB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Processing object type SCHEMA_EXPORT/DB_LINK
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/MATERIALIZED_VIEW
Processing object type SCHEMA_EXPORT/JOB
Processing object type SCHEMA_EXPORT/REFRESH_GROUP
. . exported "CORPORATE"."MVW_COSTOFGOODS_V2" 4.576 GB 31590861 rows
. . exported "CORPORATE"."TB_COSTOFGOODS2_2011" 817.7 MB 5650656 rows
. . exported "CORPORATE"."SALESINVOICEHDR" 1.918 GB 6789553 rows
. . exported "CORPORATE"."MVW_SALES13" 1.795 GB 13058630 rows
. . exported "CORPORATE"."SALESINVOICEDTL" 1.812 GB 14800698 rows
. . exported "CORPORATE"."TB_COSTOFGOODS2_2012" 1.765 GB 12301893 rows
. . exported "CORPORATE"."STOCKBATCHVALUE_2013" 1.305 GB 13628992 rows
. . exported "CORPORATE"."MVW_STOCKBATCHVALUE" 1.305 GB 13628992 rows
. . exported "CORPORATE"."STOCKBATCHVALUE" 1.305 GB 13628992 rows
. . exported "CORPORATE"."MVW_STOCKBATCHVALUE_2012" 1.171 GB 12248286 rows
. . exported "CORPORATE"."SALESSUMMARY_BKUP30122013" 1.047 GB 5636356 rows
. . exported "CORPORATE"."SALESSUMMARY_TEMP" 1.029 GB 5535489 rows
. . exported "CORPORATE"."SALESCLOSINGDTL" 437.1 MB 6599208 rows
. . exported "CORPORATE"."RECVPKTS" 272.1 MB 2759249 rows
. . exported "CORPORATE"."MVW_SALESSUMMARY" 505.7 MB 5804784 rows
. . exported "CORPORATE"."MVW_STOCKVALUESUM" 444.1 MB 2720793 rows
. . exported "CORPORATE"."STOCKSUMMARY" 404.1 MB 7191161 rows
. . exported "CORPORATE"."STOCKSUMMARY_OLD" 375.0 MB 6676708 rows
. . exported "CORPORATE"."MVW_STOCKSUMMARY" 339.4 MB 6653335 rows
. . exported "CORPORATE"."MVW_PENDINGCRFSTATUS" 304.3 MB 506551 rows
. . exported "CORPORATE"."SENDPKTS" 85.88 MB 975402 rows
. . exported "CORPORATE"."ACCOUNTSHDR" 123.6 MB 465284 rows
. . exported "CORPORATE"."TB_COSTOFGOODS2_2013" 268.4 MB 1930988 rows
. . exported "CORPORATE"."STOCKVALUE":"P0_2014" 221.8 MB 1398622 rows
. . exported "CORPORATE"."PRICELIST" 217.7 MB 1370344 rows
.
.
.
.
.
.
Master table "CORPORATE"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for CORPORATE.SYS_EXPORT_SCHEMA_01 is:
Job "CORPORATE"."SYS_EXPORT_SCHEMA_01" successfully completed at 20:33:17
Please share your valuable Feedback...