You are on page 1of 4

PERFORMING EXPORT AND IMPORT OF A DATABASE SCHEMA

EXPORT
______
1. Loging into the source database as user system useing SQLPlus, SQL Developer or
another client tool of your choice.

2. Check the available/defined directories in the database using the syntax:

select * from all_directories;

POSSIBLE QUERRY OUTPUT

OWNER DIRECTORY_NAME DIRECTORY_PATH


ORIGIN_CON_ID
---------------- ------------------
------------------------------------------------------------ -------------
SYS ORACLECLRDIR c:\app\product\12.1.0\dbhome_2\bin\clr
1
SYS SS_OE_XMLDIR c:\ade\aime_v\oracle/demo/schema/order_entry/
3
SYS XSDDIR c:\ade\aime_v\oracle/rdbms/xml/schema
3
SYS SUBDIR
c:\ade\aime_v\oracle/demo/schema/order_entry//2002/Sep 3
SYS MEDIA_DIR
c:\app\product\12.1.0\dbhome_2\demo\schema\product_media\ 3
SYS DATA_FILE_DIR
c:\app\product\12.1.0\dbhome_2\demo\schema\sales_history\ 3
SYS LOG_FILE_DIR c:\app\product\12.1.0\dbhome_2\demo\schema\log\
3

14 rows selected.

3. Create the OS directory in which you wish to place the export dump file in. e.g.
D:\datapump

4.a. While logged into the source database as user system, create a database
directory linked to the path to the directory created in step 3 above as follows:

SQL> create directory exp_dir as 'D:\datapump\';

Directory created.

SQL> grant read, write on directory exp_dir to scott;

Grant succeeded.

(User scott shall export his own full schema and save the export dump file in the
above directory)

4.b. Confirm the creation of the new directory in the database

OWNER DIRECTORY_NAME DIRECTORY_PATH


ORIGIN_CON_ID
------------ ------------------
------------------------------------------------------------ -------------
SYS ORACLECLRDIR c:\app\product\12.1.0\dbhome_2\bin\clr
1
SYS SS_OE_XMLDIR c:\ade\aime_v\oracle/demo/schema/order_entry/
3
SYS XSDDIR c:\ade\aime_v\oracle/rdbms/xml/schema
3
SYS SUBDIR
c:\ade\aime_v\oracle/demo/schema/order_entry//2002/Sep 3
SYS MEDIA_DIR
c:\app\product\12.1.0\dbhome_2\demo\schema\product_media\ 3
SYS DATA_FILE_DIR
c:\app\product\12.1.0\dbhome_2\demo\schema\sales_history\ 3
SYS LOG_FILE_DIR c:\app\product\12.1.0\dbhome_2\demo\schema\log\
3
SYS EXP_DIR D:\datapump\
3

15 rows selected

5. TAKE THE EXPORT BACKUP FOR THE SCHOTT SCHEMA AS FOLLOWS (ASSUMING YOU WANT TO
BACKUP/EXPORT THE SCHEMA FOR SCOTT):

C:\Users\user>expdp scott/tiger@pdborcl schemas=SCOTT directory=EXP_DIR


dumpfile=SCOTT.dmp logfile=expSCOTT.log

----POSSIBLE EXPORT OUTPUT-------

Export: Release 12.1.0.1.0 - Production on Thu Jun 23 23:22:28 2016

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit
Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
options
Starting "SCOTT"."SYS_EXPORT_SCHEMA_01": scott/********@pdborcl schemas=SCOTT
directory=EXP_DIR dumpfile=SCOTT.dmp logfile=expSCOTT.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 192 KB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/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/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
. . exported "SCOTT"."DEPT" 6.007 KB 4 rows
. . exported "SCOTT"."EMP" 8.757 KB 14 rows
. . exported "SCOTT"."SALGRADE" 5.937 KB 5 rows
. . exported "SCOTT"."BONUS" 0 KB 0 rows
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
D:\DATAPUMP\SCOTT.DMP
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at Thu Jun 23 23:23:53
2016 elapsed 0 00:01:19

6.a. TAKE A FULL DATABASE EXPORT AS FOLLOWS


C:\Users\LMWANGI>expdp system/Welcome1@pdborcl full=Y directory=EXP_DIR
dumpfile=pdborcl_FULL.dmp logfile=exp_pdborcl.log

6.b.TAKE A FULL DATABASE BACK WHILE SPLITING THE DUMP FILE INTO SMALLER SIZED DUMP
FILES [FOR LARGE DATABASES] WITH COMPRESSION ENABLED AS FOLLOWS

FOR A SCHEMA:

C:\Users\user>expdp scott/tiger@pdborcl schemas=SCOTT directory=EXP_DIR


dumpfile=EXP_DIR:exp_scott_13jan2017_%U.dmp filesize=2m
Logfile=EXP_DIR:exp_scott_11jan2017.log compression=all

NB 1: The valid range of dumpfile sizes is: 40KB to 16TB

FOR FULL DB

expdp system/welcome1@pdborcl full=Y directory=EXP_DIR


dumpfile=EXP_DIR:exp_full_13jan2017_%U.dmp filesize=2m
Logfile=exp_full_13jan2017.log compression=all

NB 2: If compression is enabled, the dumpfile size shall remain as specified by the


"FILESIZE" expdp parameter, but the data in the dumpfile shall be compressed. The
impdb is able to read directly from a compressed expdp during an import operation

7. Use WinSCP to securely transfer/FTP the export dump file to your cloud database
virtual machine (VM)

IMPORT
______

8. In your cloud database VM, create a database directory in a similar way to the
way you created the database directory on the export database.

9. Place/copy/move the export dump file in the cloud VM to the directory in step 8
above

10. Import the database export dump file contents into the cloud database as
follows:

C:\Users\LMWANGI>impdp system/welcome1@pdborcl remap_schema=scott:test


directory=EXP_DIR dumpfile=EXP_DIR:exp_full_13jan2017_%U.dmp
logfile=imp_test_from_scott.log

NB: The impdb is able to read directly from a compressed expdp during an import
operation

------POSSIBLE IMPORT OUTPUT---------

Import: Release 12.1.0.1.0 - Production on Thu Jun 23 23:59:19 2016

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit
Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
options
Master table "SCOTT"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_SCHEMA_01": scott/********@pdborcl schemas=SCOTT
directory=EXP_DIR dumpfile=scott.dmp logfile=impSCOT.log
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."DEPT" 6.007 KB 4 rows
. . imported "SCOTT"."EMP" 8.757 KB 14 rows
. . imported "SCOTT"."SALGRADE" 5.937 KB 5 rows
. . imported "SCOTT"."BONUS" 0 KB 0 rows
Processing object type SCHEMA_EXPORT/TABLE/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/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "SCOTT"."SYS_IMPORT_SCHEMA_01" successfully completed at Thu Jun 23 23:59:57
2016 elapsed 0 00:00:33

C:\Users\user>

11. IMPORTING FROM THE FULL DATABASE EXPORT DUMP

C:\Users\user>impdp system/Welcome1@pdborcl full=Y directory=exp_dir


dumpfile=PDBORCL_FULL.DMP logfile=imp_full.log

NOTE: THE SYNTAX IS THE SAME IRRESPECTIVE OF THE OS

You might also like