Вы находитесь на странице: 1из 4

Recovering a Table from Hot backup

Introduction:
This document provides the steps on how to recover a dropped table from
a Hot (online)
backup of the database.
Recovering a Table from Hot backup
2
Scenario :
There may some cases where a Table can be dropped accidentally by the
DBA or a developer
in a Production database environment. In this case, there needs to be a
process of recovering
only the Dropped tabled from an already existing HOT backup or the
Export / Import backup.
In 24X7 Operations, there will be less opportunity of taking an offline
backup. So, in this
document we will discuss about recovering a Dropped table from the
Online backup. Here are
the steps to do the same:
Steps to Recover the Table:
1. Since the table is dropped, we need to first recover the same using an
interim TEST
database as direct recovery is not possible. Let us consider the database
name as
TEST.
2. We need to identify the data files, control files and the log files of the
existing
production database. This can be obtained by the following :
SQL> select file_name,file_id,status,tablespace_name from dba_data_files
order by
tablespace_name desc;
Filename
File
ID Status Tablespace Name
D:\ORACLE\ORA92\<DB1>\XDB01.DBF 8 AVAILABLE XDB
D:\ORACLE\ORA92\<DB1>\UNDOTBS01.DBF 2 AVAILABLE UNDOTBS1
D:\ORACLE\ORA92\<DB1>\TOOLS01.DBF 7 AVAILABLE TOOLS
D:\ORACLE\ORADATA\<DB1>\ORWTRC.DBS 9 AVAILABLE TBSORWTRACE
D:\ORACLE\ORA92\<DB1>\SYSTEM01.DBF 1 AVAILABLE SYSTEM
D:\ORACLE\ORA92\<DB1>\INDX01.DBF 6 AVAILABLE INDX
D:\ORACLE\ORADATA\<DB1>\IMPINDEX_01.DBF 5 AVAILABLE IMPINDEX
D:\ORACLE\ORADATA\<DB1>\IMPINDEX_02.DBF 11 AVAILABLE IMPINDEX
D:\ORACLE\ORADATA\<DB1>\IMPACT2_01.DBF 4 AVAILABLE IMPACT2
D:\ORACLE\ORADATA\<DB1>\IMPACT_01.DBF 3 AVAILABLE IMPACT
Also, get the list of the Log files:
SQL> select * from v$logfile;
Group
# Status Type Member
1 ONLINE D:\ORACLE\ORA92\<DB1>\REDO01.LOG
2 ONLINE D:\ORACLE\ORA92\<DB1>\REDO02.LOG
3 ONLINE D:\ORACLE\ORA92\<DB1>\REDO03.LOG
3. Once we obtain the details of the data files and the log files, the next
step is to have
the INTERIM or the TEMP database created for doing the recovery. For
this, we may
need to copy the existing INIT.ORA file of the production database from
where we
need to get the table and get the create control file script of that
database. This can be
obtained by using the following command or you can restore it from the
previous
successful online backup:
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
Recovering a Table from Hot backup
3
The control file script will look as follows:
CREATE CONTROLFILE REUSE DATABASE "<DB1>" NORESETLOGS
NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 5
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 1588
LOGFILE
GROUP 1 'D:\ORACLE\ORA92\<DB1>\REDO01.LOG' SIZE 100M,
GROUP 2 'D:\ORACLE\ORA92\<DB1>\REDO02.LOG' SIZE 100M,
GROUP 3 'D:\ORACLE\ORA92\<DB1>\REDO03.LOG' SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'D:\ORACLE\ORA92\<DB1>\SYSTEM01.DBF',
'D:\ORACLE\ORA92\<DB1>\UNDOTBS01.DBF',
'D:\ORACLE\ORADATA\<DB1>\IMPACT_01.DBF',
'D:\ORACLE\ORADATA\<DB1>\IMPACT2_01.DBF',
'D:\ORACLE\ORADATA\<DB1>\IMPINDEX_01.DBF',
'D:\ORACLE\ORA92\<DB1>\INDX01.DBF',
'D:\ORACLE\ORA92\<DB1>\TOOLS01.DBF',
'D:\ORACLE\ORA92\<DB1>\XDB01.DBF',
'D:\ORACLE\ORADATA\<DB1>\ORWTRC.DBS',
'C:\ORACLE\ORADATA\<DB1>\UNDOTBS02.DBF',
'D:\ORACLE\ORADATA\<DB1>\IMPINDEX_02.DBF'
CHARACTER SET WE8ISO8859P1
;
In the above script, change the Keywords REUSE to SET, NORESETLOGS to
RESETLOGS
and also the database name to a TEST database name.
Instead of this, you can also use the existing the control files that have
been backed up, by just
changing the location of the files in the INIT.ORA file so that it points to
the new location
where the files are restored.
4. Restore the Data files from the previous successful backup to a
temporary location and also
make the
5. Edit the INIT.ORA file to update the correct location of the restored
control files, the
database and the Instance name to the TEST database name.
6. Set the Oracle SID value for the new database. I.e. set
ORACLE_SID=TEST. Then login to
the TEST database as SYSDBA and execute the following command to
start with the
modified INIT.ORA file as below :
STARTUP pfile = ‘D:\ORACLE\ORA92\ADMIN\inittest.ora MOUNT
7. Check for the tablespace which contains the TABLE that needs to be
recovered and drop or
mark other tablespaces as OFFLINE which does not need recovery. By
doing this, we can
Recovering a Table from Hot backup
4
expedite the process of recovery. Execute the ALTER DATABASE RENAME
FILE
command for all the data files so that it has the new location updated in
the database
dictionary views.
8. Once the above step is done, recover the database by executing the
following command :
SQL> RECOVER DATABASE UNTIL CANCEL USING BACKUP CONTROLFILE;
This will prompt you to apply for the Archive log files. So enter the location
of the log files or
just enter CANCEL which will recover the database.
9. Once the recovery is done, open the database with the RESETLOGS
option as below :
SQL> ALTER DATABASE OPEN RESETLOGS;
10. Once this is done, we need to export the TABLE that we need to
recover. Use the
following command to do the same :
EXP username/password@connectionstring file=<file.dmp>
owner=<schemaname>
tables=<tab1,tab2> rows=y grants=y consistent=y log=test1.log
This will export the table that needs to be recovered.
11. Once we have the dump, IMPORT the table to the existing production
database. Before
that please disable all the constraints, triggers and the Referential
constraints so that ROW
Rejections can be avoided. The import can be done using the following
command:
IMP username/password file=<file1.dmp> fromuser=<user1>
touser=<user1>
tables=<tab1,tab2> rows=y grants=y ignore=y buffer=100000
log=imp.log
12. Check the Import log for any errors and take corrective action based
on the same.
13. Enable all the constraints, triggers and the Referential constraints.

Вам также может понравиться