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

SAP Note

    594601 - Restore table in minimal copy of current database.  


Version   1     Validity: 10.02.2003 - active   Language   English (Master)

Header Data
Released On 27.06.2003 22:57:19
Release Status Released for Customer
Component BC-DB-ORA Oracle
Priority Recommendations / Additional Info
Category Consulting

Symptom
Because of user error (changing/deleting the contents of a table) you
need to restore and recover the database to a point in time to get the
information back to the state before the change. However you don't want
to loose all of the current changes that have been made since the user
error happened.

Other Terms
Recreate Table User Error

Reason and Prerequisites


* * * * * * * * * * WARNING   WARNING   WARNING * * * * * * * * * * * *
THIS PROCEDURE COULD LEAVE YOUR DATABASE IN AN INCONSISTENT STATE. IT
SHOULD NOT BE USED UNLESS SOMEONE FROM SAP REGIONAL OR DEVELOPMENT
SUPPORT RECOMMENDS IT TO YOU. IF YOU USE THIS ON YOUR OWN WITHOUT
THE CONSENT OF SAP YOU COULD VOID THE SUPPORT OF YOUR SYSTEM.

Solution
What you can do is to create a minimal copy of your system's database. This copy would just include
the SYSTEM tablespace, the tablespace where the table you are trying to recover exists, and the
rollback segment tablespace. Once this new copy of the database is created you
can export the table from there and then import it into the real
database.

Here are the steps that you need to perform:

Setup for this example:


------------------------
T01 is the SID of the system we want to get the data from
T00 is the SID of the system where we want to create the new small db on
T00 already has the oracle software installed
The table that I want to get the data out of is in tablespace PSAPUSER1D

Step 1:
--------
On the target machine create the following directories under the
orat00 id:
          /oracle/T01/sapdata1/cntrl
          /oracle/T01/sapdata2/cntrl
          /oracle/T01/sapdata3/cntrl
          /oracle/T01/sapdata1/system_1
          /oracle/T01/sapdata1/roll_1
          /oracle/T01/sapdata2/user1d_1
          /oracle/T01/sapdata2/user1d_2
          /oracle/T01/sapdata2/user1d_3
          /oracle/T01/saparch
          /oracle/T01/saptrace
          /oracle/T01/saptrace/background

    *NOTE* you may have to create more sapdata directories. You should
           create the ones that match the original location for the
           datafiles that you are copying over. The same is true for
           the controlfile locations.

Step 2:
--------
Restore the following files onto the target (T00) box from the
production box (T01):
    - all the datafiles from the following tablespaces:
         1) system tablespace
         2) rollback tablespace
         3) tablespace that contains the object that you want to export
    - the controlfiles
    - init<SID>.ora file

    - if you want to start recovery or you are restoring from an online
      backup copy all archive files necessary

    - if you do not want to start recovery after the restore and if it
      is not from an online backup, also restore the online redologfiles
      files
Step 3:
--------
Set the two following environment varibles to the SID of your
productive system on your target system.
    setenv ORACLE_SID T01
    setenv SAPDATA_HOME /oracle/T01
Step 4:
--------
Startup the database in mount mode:
    sqlplus '/ as sysdba'
    SQL> startup mount

Step 5:
--------
Take all non-essential datafiles offline:
    SQL> set linesize 132 pagesize 30000
    SQL> spool df_offline.sql
    SQL> select 'alter database datafile '|| '''' || name
            || '''' ||  ' offline drop;'
           from v$datafile
          where status NOT in ('SYSTEM')
            and name not like '%roll%'
            and name not like '%<tablespace-identifier>%';

            <tablespace-identifier> should be the name of your


            tablespace without the PSAP part.

            e.g. tablespace-name PSAPUSER1D --> identifier is user1d


                                                          (lowercase)     SQL> spool off
    - now goto OS-level (in a different window) where the
      file df_offline.sql exists
    - delete the first few and last few lines so that only the lines
      that start with 'alter database.... ' remain
    - run the script:       SQL> @df_ofline.sql

Step 6:
--------
If you want to recover the database

    - make sure you have the archive files you need.
    - SQL> recover database until cancel using backup controlfile;
    - SQL> alter database open resetlogs;

Step 7:
--------
If no recovery is required:
    - SQL> alter database open;

Step 8:
--------
You now can start the export of the table in question
    exp sapr3/<passwd> tables=<table_name> file=<table_name>.dmp
    log=./<tablename>.log

Step 9:
--------
Now copy the export file over to your productive system and
import it there

Validity
This document is not restricted to a software component or software component version

References
This document refers to:
SAP Notes
605062   FAQ: Restore and recovery
This document is referenced by:
SAP Notes (1)
605062   FAQ: Restore and recovery

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