Thursday 17 October 2013

Exoprt and Import Schema

Hi Friends hope my previous post helped at-least some of you.
Taking export and import of schemas is a day to day activity for DBAs and other Oracle practitioners. The Data pump technique is one of the most convenient one.

Three steps to export a schema:-
Step 1 --> Create a directory for the dump files location--
Say location name is /TESTDB/SchemaDump/ ----- (for Linux, HP-UX, IBM-AIX, etc)
eg:-
$cd /TESTDB
$mkdir  SchemaDump
$cd  SchemaDump

 Step 2 --> Create virtual directory and grant permissions (schema say TestSchema) --
eg :-
Connect to sql and use the following commands--

create directory dump_dir as '/TESTDB/SchemaDump/';

grant read,write on directory dump_dir to TestSchema;
Grant succeeded.


 Step 3 --> Take the export --
eg:-
$expdp system@<database name with domain> schemas=TestSchema LOGFILE=TestSchema.log DUMPFILE=TestSchema.dmp flashback_time=systimestamp DIRECTORY=dump_dir

This command will create the dump and log file in the location "/TESTDB/SchemaDump"
flashback_time=systimestamp ---> This is optional
Please give the system password to process.

Command to import a schema:-
You should have the dump file located in the dump directory, once it is done use the following command:-
eg:-
$impdp system@<database name with domain> schemas=TestSchema directory=dump_dir dumpfile=TestSchema.dmp logfile=TestSchemaImp.log
Please give the system password to process.

This technique can also be used to export and import Tables as-well, the export backup of an entire database is also possible. The syntax for Table export is almost the same, please feel free to question if any one face any issues in using the commands.

Please comment if something needs to be added. Good Luck.!

2 comments:

  1. For the reason that the admin of this web site is working, no hesitation very soon it will be well-known, due to its feature
    contents.

    My homepage; csr Racing cheats

    ReplyDelete