Oracle Export and Import
Oracle Export and Import
To export the entire database to a single file dba.dmp in the current directory.
- Login to server
exp SYSTEM/password FULL=y FILE=dba.dmp LOG=dba.log CONSISTENT=y
or
exp SYSTEM/password PARFILE=params.dat
FILE=dba.dmp
GRANTS=y
FULL=y
ROWS=y
LOG=dba.log
To dump a single schema to disk (we use the scott example schema here)
Using imp:
To import just the dept and emp tables from the scott schema
In each example, you are shown how to use both the command-line
method and the parameter file method. Some examples use vertical
ellipses to indicate sections of example output that were too long to
include.
Only users with the DBA role or the EXP_FULL_DATABASE role can
export in full database mode. In this example, an entire database is
exported to the file dba.dmp with all GRANTS and all data.
FILE=dba.dmp
GRANTS=y
FULL=y
ROWS=y
Command-Line Method
> exp FULL=y FILE=dba.dmp GRANTS=y ROWS=y
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Status
messages are written out as the entire database is exported. A final
completion message is returned when the export completes
successfully, without warnings.
FILE=scott.dmp
OWNER=scott
GRANTS=y
ROWS=y
COMPRESS=y
Command-Line Method
> exp scott/tiger FILE=scott.dmp OWNER=scott GRANTS=y
ROWS=y COMPRESS=y
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
. about to export SCOTT's tables via Conventional
Path ...
. . exporting table BONUS
0 rows exported
. . exporting table DEPT
4 rows exported
. . exporting table EMP
14 rows exported
. . exporting table SALGRADE
5 rows exported
.
.
.
Export terminated successfully without warnings.
In table mode, you can export table data or the table definitions. (If no
rows are exported, the CREATE TABLE statement is placed in the
export file, with grants and indexes, if they are specified.)
Command-Line Method
> exp FILE=expdat.dmp TABLES=(scott.emp,blake.dept)
GRANTS=y INDEXES=y
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
About to export specified tables via Conventional
Path ...
Current user changed to SCOTT
. . exporting table EMP
14 rows exported
Current user changed to BLAKE
. . exporting table DEPT
8 rows exported
Export terminated successfully without warnings.
FILE=blake.dmp
TABLES=(dept,manager)
ROWS=y
COMPRESS=y
Command-Line Method
> exp blake/paper FILE=blake.dmp TABLES=(dept, manager)
ROWS=y COMPRESS=y
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
FILE=misc.dmp
TABLES=(scott.%P%,blake.%,scott.%S%)
Command-Line Method
> exp FILE=misc.dmp TABLES=(scott.%P%,blake.%,scott.%S
%)
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
About to export specified tables via Conventional
Path ...
Current user changed to SCOTT
. . exporting table DEPT
4 rows exported
. . exporting table EMP
14 rows exported
Current user changed to BLAKE
. . exporting table DEPT
8 rows exported
. . exporting table MANAGER
4 rows exported
Current user changed to SCOTT
. . exporting table BONUS
0 rows exported
. . exporting table SALGRADE
5 rows exported
Export terminated successfully without warnings.
TABLES=(emp)
ROWS=y
Command-Line Method
> exp scott/tiger TABLES=emp rows=y
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
About to export specified tables via Conventional
Path ...
. . exporting table EMP
. . exporting partition M
8 rows exported
. . exporting partition Z
6 rows exported
Export terminated successfully without warnings.
TABLES=(emp:m)
ROWS=y
Command-Line Method
> exp scott/tiger TABLES=emp:m rows=y
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
About to export specified tables via Conventional
Path ...
. . exporting table EMP
. . exporting partition M
8 rows exported
Export terminated successfully without warnings.
TABLES=(emp:m,emp:sp4)
ROWS=y
Command-Line Method
> exp scott/tiger TABLES=(emp:m, emp:sp4) ROWS=y
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
About to export specified tables via Conventional
Path ...
. . exporting table EMP
. . exporting composite partition M
. . exporting subpartition SP1
1 rows exported
. . exporting subpartition SP2
3 rows exported
. . exporting composite partition Z
. . exporting subpartition SP4
1 rows exported
Export terminated successfully without warnings.
FILE=dba.dmp
SHOW=n
IGNORE=n
GRANTS=y
FROMUSER=scott
TABLES=(dept,emp)
Command-Line Method
> imp FILE=dba.dmp FROMUSER=scott TABLES=(dept,emp)
Import Messages
Information is displayed about the release of Import you are using and
the release of Oracle Database that you are connected to. Status
messages are also displayed.
This example illustrates importing the unit and manager tables from
a file exported by blake into the scott schema.
FILE=blake.dmp
SHOW=n
IGNORE=n
GRANTS=y
ROWS=y
FROMUSER=blake
TOUSER=scott
TABLES=(unit,manager)
Command-Line Method
> imp FROMUSER=blake TOUSER=scott FILE=blake.dmp
TABLES=(unit,manager)
Import Messages
Information is displayed about the release of Import you are using and
the release of Oracle Database that you are connected to. Status
messages are also displayed.
FILE=scott.dmp
FROMUSER=scott
TOUSER=blake
TABLES=(*)
Command-Line Method
> imp FILE=scott.dmp FROMUSER=scott TOUSER=blake
TABLES=(*)
Import Messages
Information is displayed about the release of Import you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
Warning: the objects were exported by SCOTT, not by you
In this example, emp is a partitioned table with three partitions: P1, P2,
and P3.
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
About to export specified tables via Conventional
Path ...
. . exporting table EMP
. . exporting partition P1
7 rows exported
. . exporting partition P2
12 rows exported
. . exporting partition P3
3 rows exported
Export terminated successfully without warnings.
In a partition-level Import you can specify the specific partitions of an
exported table that you want to import. In this example, these are P1
and P3 of table emp:
Import Messages
Information is displayed about the release of Import you are using and
the release of Oracle Database that you are connected to. Status
messages are also displayed.
Export Messages
Information is displayed about the release of Export you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
About to export specified tables via Conventional
Path ...
. . exporting table EMP
. . exporting composite partition P1
. . exporting subpartition P1_SP1
2 rows exported
. . exporting subpartition P1_SP2
10 rows exported
. . exporting subpartition P1_SP3
7 rows exported
. . exporting composite partition P2
. . exporting subpartition P2_SP1
4 rows exported
. . exporting subpartition P2_SP2
2 rows exported
Export terminated successfully without warnings.
Import Messages
Information is displayed about the release of Import you are using and
the release of Oracle Database that you are connected to. Then, status
messages similar to the following are shown:
.
.
.
. importing SCOTT's objects into SCOTT
. . importing subpartition "EMP":"P1_SP2"
10 rows imported
. . importing subpartition "EMP":"P1_SP3"
7 rows imported
. . importing subpartition "EMP":"P2_SP1"
4 rows imported
. . importing subpartition "EMP":"P2_SP2"
2 rows imported
Import terminated successfully without warnings.
This example assumes the emp table has two partitions based on the
empno column. This example repartitions the emp table on the deptno
column.
Perform the following steps to repartition a table on a different column:
The following SQL SELECT statements show that the data is partitioned
on the deptno column:
FILE=scott.dmp
IGNORE=n
GRANTS=y
ROWS=y
FROMUSER=scott
TABLES=(%d%,b%s)
Command-Line Method
imp FROMUSER=scott FILE=scott.dmp TABLES=(%d%,b%s)