Wednesday, February 8, 2012

Creating a dump and restoring an Oracle database

These days I am involved in testing a migration tool which demands in testing the application's migration against several databases. In the process it is very useful if a loaded database can be backed-up to restore later.

This is how you create a database dump of an oracle database and restore it.

1. First you need to connect to oracle as sysdba, create a user and grant him required privileges. Command line steps for creating a user and granting privileges are as below;
C:\app\Administrator\OraHome_1\BIN>sqlplus sys as sysdba;

SQL*Plus: Release 11.1.0.7.0 - Production on Tue Jan 10 17:28:47 2012

Copyright (c) 1982, 2008, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> drop user yumani cascade;

User dropped.

SQL> Create user yumani identified by yumani account unlock;

User created.

SQL> grant create session, dba to yumani;

Grant succeeded.

SQL> grant connect to yumani;

Grant succeeded.

SQL> exit

2.  Fill in your database with data.

3. Next, lets create a database dump.
$ expdp yumani/yumani schemas=yumani dumpfile=yumani100112_1657.dmp
An oracle dump with the name yumani100112_1657.dmp will be created in the location that you ran the above command.

4. After backing-up if you need to restore the dump, do as below.
$ impdp yumani/yumani schemas=yumani dumpfile=YUMANI100112_1640.DMP 

4 comments:

  1. impdp in simple formatted way

    impdp NEW_OWNER/NEW_OWNER_PW SCHEMAS=OLD_OWNER REMAP_SCHEMA=OLD_OWNER:NEW_OWNER DUMPFILE=YUMANI100112_1640.DMP LOGFILE=YUMANI100112_1640.DMP.log

    Oracle Data Pump utility is used for exporting data and metadata into set of operating system files and it is newer, faster and flexible alternative to “export/import”

    ReplyDelete
  2. For us to make it working w've remove the schemas options.
    One thing to take care is the path of the dump file, no absolute path.

    Another trick is to define the oracle_home and the oracle_sid and then you're !

    ReplyDelete
  3. Nice Post! I appreciate to you for this post. Really you are the best. Oracle Java Dumps

    ReplyDelete

Featured

Selenium - Page Object Model and Action Methods

  How we change this code to PageObjectModel and action classes. 1 2 3 driver . findElement ( By . id ( "userEmail" )). sendKeys (...

Popular Posts