Export And Import

«« Previous
Next »»

These tools are used to transfer data from one oracle database to another oracle database. You Export tool to export data from source database, and Import tool to load data into the target database. When you export tables from source database export tool will extracts the tables and puts it into the dump file. This dump file is transferred to the target database. At the target database the Import tool will copy the data from dump file to the target database.

From Ver. 10g / 11g Oracle has also released Data Pump Export and Import tools, which are enhanced versions of original Export and Import tools.

The export dump file contains objects in the following order:

1. Type definitions
2. Table definitions
3. Table data
4. Table indexes
5. Integrity constraints, views, procedures, and triggers
6. Bitmap, function-based, and domain indexes

When you import the tables the import tool will perform the actions in the following order, new tables are created, data is imported and indexes are built, triggers are imported, integrity constraints are enabled on the new tables, and any bitmap, function-based, and/or domain indexes are built. This sequence prevents data from being rejected due to the order in which tables are imported. This sequence also prevents redundant triggers from firing twice on the same data

Invoking Export and Import


You can run Export and Import tool in two modes

            Command Line Mode

            Interactive Mode

When you just type exp or imp at o/s prompt it will run in interactive mode i.e. these tools will prompt you for all the necessary input. If you supply command line arguments when calling exp or imp then it will run in command line mode

Command Line Parameters of Export tool


You can control how Export runs by entering the EXP command followed
by various arguments. To specify parameters, you use keywords:

     Format:  EXP KEYWORD=value or KEYWORD=(value1,value2,...,valueN)

     Example: EXP SCOTT/TIGER GRANTS=Y TABLES=(EMP,DEPT,MGR)

               or TABLES=(T1:P1,T1:P2), if T1 is partitioned table

Keyword                               Description (Default)
-------------------------------------------------------------------------------------
USERID                                 username/password
BUFFER                                 size of data buffer
FILE                                      output files (EXPDAT.DMP)
COMPRESS                          import into one extent (Y)
GRANTS                               export grants (Y)
INDEXES                               export indexes (Y)
DIRECT                                  direct path (N)
LOG                                       log file of screen output
ROWS                                   export data rows (Y)
CONSISTENT                       cross-table consistency(N)
FULL                                    export entire file (N)
OWNER                               list of owner usernames
TABLES                                 list of table names
RECORDLENGTH                  length of IO record
 INCTYPE                              incremental export type
 RECORD                              track incr. export (Y)
TRIGGERS                            export triggers (Y)
STATISTICS                         analyze objects (ESTIMATE)
PARFILE                               parameter filename
CONSTRAINTS                     export constraints (Y)
OBJECT_CONSISTENT          transaction set to read only during object export (N)
FEEDBACK                           display progress every x rows (0)
FILESIZE                              maximum size of each dump file
FLASHBACK_SCN                 SCN used to set session snapshot back to
FLASHBACK_TIME               time used to get the SCN closest to the specified time
QUERY                                  select clause used to export a subset of a table
RESUMABLE                        suspend when a space related error is encountered(N)
RESUMABLE_NAME             text string used to identify resumable statement
RESUMABLE_TIMEOUT       wait time for RESUMABLE
TTS_FULL_CHECK              perform full or partial dependency check for TTS
TABLESPACES                     list of tablespaces to export
TRANSPORT_TABLESPACE    export transportable tablespace metadata (N)
TEMPLATE                           template name which invokes iAS mode export

The Export and Import tools support four modes of operation

FULL             :Exports all the objects in all schemas
OWNER         :Exports objects only belonging to the given OWNER
TABLES         :Exports Individual Tables
TABLESPACE  :Export all objects located in a given TABLESPACE.

Example of Exporting Full Database


The following example shows how to export full database

$exp USERID=scott/tiger FULL=y FILE=myfull.dmp

In the above command, FILE option specifies the name of the dump file, FULL option specifies that you want to export the full database, USERID option specifies the user account to connect to the database. Note, to perform full export the user should have DBA or EXP_FULL_DATABASE privilege.

Example of Exporting Schemas


To export Objects stored in a particular schemas you can run export utility with the following arguments

$exp USERID=scott/tiger OWNER=(SCOTT,ALI) FILE=exp_own.dmp

The above command will export all the objects stored in SCOTT and ALI’s schema.

Exporting Individual Tables


To export individual tables give the following command

$exp USERID=scott/tiger TABLES=(scott.emp,scott.sales) FILE=exp_tab.dmp

This will export scott’s emp and sales tables.

Exporting Consistent Image of the tables


If you include CONSISTENT=Y option in export command argument then, Export utility will export a consistent image of the table i.e. the changes which are done to the table during export operation will not be exported.

«« Previous
Next »»

0 comments:

Post a Comment