Table Truncated, Flashback is enabled ... How to recover.

Hi,
There is a table which was truncated, as we have flashback enabled. Even we have previously enabled row movement of the particular table.
How to recover ????
Thanks.

hi,
There are three options available:
1. Restore and recover the primary database to a point in time before the drop.
This is an extreme measure for one table as the entire database goes back in
time.
2. Restore and recover the tablespace to a point in time before the drop.
This is a better option, but again, it takes the entire tablespace back in time.
3. Restore and recover a subset of the database as a DUMMY database to export
the table data and import it into the primary database. This is the best option
as only the dropped table goes back in time to before the drop.
For the first, see information on performing incomplete recovery on a database.
The second and third options are virtually the same, it depends if the entire
tablespace data should be taken back in time, or just recovering the one table.
The tablespace point in time recovery (TSPITR) may be useful if there are
dependencies between the dropped/truncated table and other tables in the
database. For the second option, see RMAN documentation on TSPITR and/or Note 180436.1 RMAN Tablespace Point in Time Recovery Example. Both procedures
for the second and third options are very much the same. The differences are
that the TABLE PITR has to be exported/imported manually while the TABLESPACE
PITR is fully automated by RMAN.
This article will deal with the third option.
General overview of procedure to recover from a DROP or TRUNCATE table by using RMAN.
To recover from a dropped or truncated table, a dummy database (copy of primary)
will be restored and recovered to point in time so the table can be exported.
Once the table export is complete, the table can be imported into the primary
database. This dummy database can be a subset of the primary database. However,
the 'dummy' database must include the SYSTEM, UNDO (or ROLLBACK), and the
tablespace(s) where the dropped/truncated table resides.
The simpliest method to create this 'dummy' database is to use the RMAN
duplicate command. See:Note 228257.1 RMAN Duplicate Database in Oracle9iNote 73912.1 RMAN Creating a Duplicate Database -- Oracle8i
The difference between the two versions is that Oracle9i duplicate command
allows for a 'SKIP TABLESPACE' option. Thus Oracle9i allows for a duplication
of a subset of the database.
In Oracle8i, you cannot 'skip' tablespaces when using duplicate, so you must
duplicate the entire database. If this is not a desired option, or you must
restore the original database and thus cannot use
the rman DUPLICATE.
NOTE: The remainder of this information is for users who cannot use the
DUPLICATE command in Oracle8i. I.e., you want to restore only a subset
of the Oracle8i database.
Requirements :
a) RMAN backup of the primary database should be available to the
host where it has to be restored on.
b) Use of an RMAN-catalog database
c) Auxiliary instance created and started in NOMOUNT
(See Note 180436.1 step I. Create the auxiliary initSID.ora.)
Create this from the init.ora of the primary database and:
!!!!! IMPORTANT !!!!!!!!
If using the same host as the primary, be VERY careful as you do not want to
restore on top of existing files being used by the primary (production database).
Doing so can corrupt and crash the production database!!!!!!
- be sure all paths for this AUX instance are different than primary.
- be sure CONTROL_FILES parameter has different location but more importantly DIFFERENT NAME.
- add LOCK_NAME_SPACE to any value other than the primary database name.
- change/add SERVICE_NAME=AUX1.
- use the SAME DB_NAME as for the production database
- BE SURE you include the 'alter database rename file' command at the end
of the script. This changes the location and/or name of the online
redo log files.
d) Set ORACLE_HOME and ORACLE_SID set to the auxiliary instance
e.q set ORACLE_SID=AUX1
set ORACLE_HOME=<....>
!!!!! IMPORTANT !!!!!!!!
1: Restore and recover the tablespace
The restore and recovery is done by RMAN. Create a file
of the script below (e.q table_pitr.cmd) and execute the following
command :
$ rman cmdfile=table_pitr.cmd
NOTE: ORACLE_HOME and ORACLE_SID set to the auxiliary instance
NOTE: The Auxiliary instance IS the target to rman at this point.
The RMAN-script :
connect catalog rman/rman@v920_nlsu31
connect target /
run
allocate channel t1 type sbt_tape
parms='SBT_LIBRARY=/home/usupport/liblsm.so';
set until time "to_date( '09-10-2005 06:00', 'DD-MM-RRRR HH24:MI')";
restore controlfile;
sql "alter database mount clone database";
set newname for datafile 1 to '/fs01/oradata/tspitr/system01.dbf';
set newname for datafile 2 to '/fs01/oradata/tspitr/undotbs01.dbf';
set newname for datafile 4 to '/fs01/oradata/tspitr/tools01.dbf';
restore tablespace system, undotbs1, tools;
switch datafile all;
sql "alter database datafile 1,2,4 online";
recover database skip forever tablespace TEMP,INDX,USERS,OLTS_ATTRSTORE,
OLTS_CT_DN,OLTS_CT_CN, OLTS_CT_OBJCL,OLTS_CT_STORE,OLTS_DEFAULT,
OLTS_TEMP,OLTS_IND_ATTRSTORE,
OLTS_IND_CT_DN,OLTS_IND_CT_CN,
OLTS_IND_CT_OBJCL,OLTS_IND_CT_STORE,
P1TS_ATTRSTORE,P1TS_IND_STORE;
sql "alter database rename file ''/fs01/oradata/primary/REDO01.LOG'' to ''/fs01/oradata/tspitr/REDO01.LOG''";
sql "alter database rename file ''/fs01/oradata/primary/REDO02.LOG'' to ''/fs01/oradata/tspitr/REDO02.LOG''";
sql "alter database rename file ''/fs01/oradata/primary/REDO03.LOG'' to ''/fs01/oradata/tspitr/REDO03.LOG''";
/* NOTE: Syntax within rman is two single quotes around each name, this may be operating system specific. */
release channel t1;
Explanation :
- Tape channel allocated, but could also be a disk channel, depending
on where the backups are.
- SET UNTIL TIME
User specified time, just before the DROP/TRUNACTE table
- MOUNT CLONE DATABASE.
This forces all datafiles to be put OFFLINE. Just for safety reasons.
- SET NEWNAME
New path for the datafile to be restored. Keep in mind that this is
done on the auxiliary instance and should NOT interfere/overwrite the
prodution database.
- ALTER DATABASE RENAME FILE
This is required to change the location of the online log files. When the
'resetlogs' is issued, Oracle will create online logs based on specification
in the controlfile. This command changes the location and/or name. If
this is being performed on the SAME server, not issuing a rename will
cause Oracle to reset the production online log files. This will corrupt
and crash the production database!!!!!!
- RESTORE TABLESPACE ...;
Restore the tablespaces which need to be recoverd.
This includes always the SYSTEM, rollback/undo tablespace and
the tablespace(s)where the dropped/truncated table resides.
The SYSTEM tablespace is always included as it containts most / all of
the objects owned by SYS and SYSTEM. Some other tablespaces might be
included as well when they contain objects owned by SYS and SYSTEM.
SQL> select distinct tablespace_name
from dba_segments where owner in ('SYS', 'SYSTEM');
- SWITCH DATAFILE ALL;
Make the changes in the pathname (set by SET NEWNAME) active in the
controlfile.
- ALTER DATABASE DATAFILE ... ONLINE
Online the datafiles which are restored and have to be recovered.
- RECOVER DATABASE SKIP FOREVER TABLESPACE ......;
You need to specify the complete list of tablespaces which will not be
recovered. Else the recovery fails, that it cannot dentify/file the
tablespace datafile. The SKIP FOREVER clause causes RMAN to take the
datafiles offline using the DROP option. Only use skip forever when the
specified tablespaces will be dropped after opening the database. I.e.,
all tablespaces except the one which contains your data.
The recovery of RMAN, checks the datafileheaders, to get a starting point
for the recovery.
2: Open auxiliary database with RESETLOGS
$ sqlplus /
SQL> alter database open resetlogs;
This step should ALWAYS be executed outside RMAN via SQL*Plus. If the open
is executed in RMAN it may effect the primary database's entry in the RMAN
catalog. Backups will fail with messages like:
RMAN-20011 "target database incarnation is not current in recovery catalog"
3: Export the table
The database is recovered and open, so it can be used by export.
Example:
$ exp userid=system/<password> file=table.dmp
tables=(<owner>.<tablename>, ...) rows=Y
4: Import the export-dump
Import the data of the dropped table back into the primary/production database.
Example:
$ imp userid=system/<password> file=table.dmp ignore=Y
5: Remove this AUX/DUMMY database
Shutdown and remove all files associated with this database. It has satisfied
your purpose. I.e., to give you an export of this table.

Similar Messages

  • How can recover the dropped table on oracle 9i and 10g ?

    This is the scnario...
    user dropped one table on his schema...
    oracle 10g DB
    flashback not enabled so no flashback drop possible
    but any way to recover it from recyclebin on 10g ? becuase this is not sysdba table ...if yes how about on 9i...if yes then will there be any limit on recycle bin like space pressure ??
    Scnario 2:
    we have two online redo log group with 2 member each..
    my currnet online redolog group currupted (including members)...we need the data's of that currnet group so we should'nt use the clear log command
    how to recover it ?
    Do we need to go for any block level revcovery ?
    thanks
    Moorthy
    Edited by: user13014926 on Jan 18, 2011 6:55 AM

    If you have no backup your only option is to perform incomplete recovery (point-in-time recovery) to the time just before the drop, export the table and then restore the database (for example, from a cold backup taken just before the incomplete recovery,) and import the table. This obviously requires a full backup
    taken before the drop which you don't seem to have, so the answer is "regrettably no."
    If you have a backup;
    Take backup of ur current db, apply previous day backup, do point in time recovery to get table back,export table, shutdown and apply latest backup, import table back
    Regards,

  • How to recover the data from a  dropped table in production/archive mode

    How to recover the data/change on a table that was dropped by accident.
    The database is on archive mode.

    Oracle Version. ? If 10g.
    Try this Way
    SQL> create table taj as select * from all_objects where rownum <= 100;
    Table created.
    SQL> drop table taj ;
    Table dropped.
    SQL> show recyclebin
    ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
    TAJ              BIN$b3MmS7kYS9ClMvKm0bu8Vw==$0 TABLE        2006-09-10:16:02:58
    SQL> flashback table taj to before drop;
    Flashback complete.
    SQL> show recyclebin;
    SQL> desc taj;
    Name                                      Null?    Type
    OWNER                                              VARCHAR2(30)
    OBJECT_NAME                                        VARCHAR2(30)
    SUBOBJECT_NAME                                     VARCHAR2(30)
    OBJECT_ID                                          NUMBER
    DATA_OBJECT_ID                                     NUMBER
    OBJECT_TYPE                                        VARCHAR2(19)
    CREATED                                            DATE
    LAST_DDL_TIME                                      DATE
    TIMESTAMP                                          VARCHAR2(19)
    STATUS                                             VARCHAR2(7)
    TEMPORARY                                          VARCHAR2(1)
    GENERATED                                          VARCHAR2(1)
    SECONDARY                                          VARCHAR2(1)
    SQL>M.S.Taj

  • How to recover a perged table?----

    How to recover a perged table?----No.139

    For some reason I thought I saw dropped the first time through the thread. Flashback table is only used to restore dropped tables from the recycling bin.

  • Corrupted innodb table crashing mysql instance how to recover table?

    Hello,
    Running a simple query against corrupted innodb table is crashing mysql instance .
    table test.xyz got corrupt during crash and truncate table command was in progressing when mysql crash , now
    running a simple select * query is also crashing db .
    mysql> use test;
    Database changed
    mysql> select * from xyz;
    ERROR 2013 (HY000): Lost connection to MySQL server during query
    mysql>
    mysql>
    mysql> select * from xzy;
    ERROR 2006 (HY000): MySQL server has gone away
    No connection. Trying to reconnect...
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    ERROR:
    Can't connect to the server

    Try to start mysql with innodb_force_recovery = 6
    Or to try to restore by means of the tool:
    MySql Recovery Toolbox and find out how you can use the corrupt MySQL recovery tool for damaged database restoration and easily repair known issues or already known problems, occurred in MySql files. This MySql repair utility offers many benefits
    like:
    Supports all MySql file versions and parses even very large documents on older PC computers;
    Supports primary and external keys, tables, views, indexes and other objects;
    Allows previewing recovered data in freeware mode so you can get results without purchasing MySql Recovery Toolbox
    For more information: http://www.mysqlrecoverytoolbox.com/
    As you can look for the answer here:
    http://www.filerepairforum.com/forum/databases/databases-aa/mysql/197-corrupted-innodb-table-crashing-mysql-instance-how-to-recover-table

  • How to recover a table from a coldback?

    Hi:
    I was asked in an interview. if a user deleted a table, how to recover it from a coldback? Please give me the steps.
    Thank you and regards.

    1. Take a cold backup of the current database.
    2. Restore the full old backup from tape/disk etc.
    3. Oracle Export the table that needs recovering.
    4. Shutdown the database.
    5. Restore the database from the first step.
    6. Start the database.
    7. Oracle Import the table from the third step.
    Hope this helps.
    Best regards,
    Mark.

  • How to recover from Large Volume Table Insert

    We are inserting 1 Million rows into table using ODI IKM Append. If half the way thru the job fails because of tablespace or other issue, how to recover? Does 50% rows are commited to db? What is the best way to handle this type of situation?

    You can have different options for this.. You can commit them in every 1000 rows in the KM.You can also set the dml operation into one transaction and commit the same at the end of step.
    Try to follow load plan for better restart options. If you cann't provide more undo table space then try loading less amount of records lets say 1 to 100,000 and then 100,001 to 200,000 like this which is little bit complex but you have to sacrifice something to overcome the issue.
    I believe you must have data in C$ and I$ step. Hence you process these data instead of loading again from original source. So it depends on you, how you are going to design the total process. You can better judge it. Talk with your dba about this issues as well.
    Thanks
    http://bhabaniranjan.com/

  • Sysjobhistory table corrupted how to recover on sql 2008 r2

    sysjobhistory table corrupted how to recover ron sql 2008 r2

    Is it anything related to Master Data Services or just a generic question for SQL Server Agent?
    I guess its generic question and must be moved to database engine forum
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • Recovering table from Flashback getting error

    Recovering table from Flashback getting error what is the reson
    1* FLASHBACK TABLE "BIN$e7TIAEKgSYO2WJ0L+hNuTA==$0" TO BEFORE DROP
    SQL> /
    FLASHBACK TABLE "BIN$e7TIAEKgSYO2WJ0L+hNuTA==$0" TO BEFORE DROP
    ERROR at line 1:
    ORA-38312: original name is used by an existing object

    This droped object original name is now taken by some other object in database so u can give this cmd like
    FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST2;
    it recover the table test and give the name as test2 because test table is already exist and that is created while this table is in recyclebin.

  • How to recover my passcode number to enable my ipad

    how to recover my passcode number to enable my ipad

    You're saying you forgot the device passcode and have a disabled device?
    http://support.apple.com/kb/HT1212

  • How to recover AP that's no longer visible in controller after bridge mode enabled?

    How to recover and troubleshoot an AP that was changed to bridge mode and subsequently lost connection to the controller?  Tried toggling switch ports to force reboot, however unsuccessful.  Curious if there's a solution without having to manually get to these APs.
    Thanks!

    Hi,
    In order to configure the bridge in Local Mode, complete these steps:
    Go to the WLC GUI and choose Wireless. It displays the list of APs that are currently registered to the WLC. Click on the AP for which you need to change the mode.
    Check the option AP mode. If it says Bridge, then change it back to Local. This changes the Bridge AP to Normal AP.
    Regards
    Dont forget to rate helpful posts

  • Table Truncated

    Hi Folks,
    I have TRUNCATED a table (for testing), now i want to recover it.
    Can anyone please assist how to accomplish this task.
    Thanks.

    sorry doesn't work that way. A restore cannot be done for specific tables.
    The Flashback utility could do this task, but in Oracle9i it isn't that advanced.
    When the truncate command is still in de retention period of undo management, you could do a flashback query. In this way you can retrieve the records as they were at the time of the truncate command.
    Is your retention period long enough (UNDO_RETENTION in init.ora)

  • Dead Hard Drive - How to Recover?

    The hard drive in my iMac recently "died". The Apple Store diagnosed my problem as a failed drive.
    Luckily, they allowed me to borrow my failed drive for a couple of days. I was able to use an external USB enclosure and Data Rescue II to recover all of my data to an external drive. Unfortunately, the recovery does not provide a disk image but rather just the folder/file structure from the original drive.
    The Apple Store has replaced my drive (under Apple Care Warranty) and now I have an iMac with a fresh install of OS X and nothing else.
    Is there a documented procedure on how to recover my home-user folders (including Library), the system Applications folder, and the System Library folder to bring my refreshed Mac back to the previous state?

    Kevin,
    Tailor these instructions to match whatever you have done so far within the new installation...
    1) Create new accounts within the new installation, using the exact same usernames and short names that existed in the old installation.
    2) Enable the "root" account, then log in as root.
    3) From the root account, navigate to the "Users" folder. Move all of the newly created HOME folders to the trash. Connect the drive that houses the backed up data, and locate the same-named HOME folders there. Drag them to the new "Users" folder, replacing the folders you moved to the trash.
    4) Open /Applications/Utilities/Terminal. At the prompt, type the following:
    <pre style="overflow:auto; font-family: 'Monaco'; font-size: 10px">chown -R username:staff /Users/username</pre>
    In the text above, you will replace all instances of "username" with the short name for a replaced account. If the short name is "fred," for example, you will type the following exactly:
    <pre style="overflow:auto; font-family: 'Monaco'; font-size: 10px">chown -R fred:staff /Users/fred</pre>
    Verify that the text is correct, then press <RETURN>. When you return to the prompt, perform the same task for the next replaced account, or quit Terminal.
    5) Log into the replaced accounts to test that everything works as expected. If so, log back into the root account, empty the trash, then log out of and disable the root account.
    It would be best if you just reinstalled any third-party applications. Keep in mind that the data, settings, etc. for those applications already exist within the restored HOME folders.
    Scott

  • How to recover a missing program

    Hi guys
    Im facing an issue on our SLM system where one of the Z programs is missing. I've checked on SE38 and the program is not listed. I have tried to check on Version Management but there are no previous versions.
    The only activity was a EHP 1 Upgrade, but there are no indications where this program  was modified or deleted.
    I've checked the table TADIR and is present. Also checked table TSTC for the transaction name ZPWC and is also in there.
    Since i dont have the original transport since its was brought from an external system, I'd like to check with you guys any idea on how to recover this program. I dont have any clue on how is missing since its not a developement system.
    Any recommendation on how to restore/find this program, would be highly appreciated.
    Martin
    PS: Also Checked in table VRSD if there is an entry with OBJTYPE = u2018REPSu2019 and OBJNAME = name of the deleted program and no luck.
    Edited by: Martin Simois on Jan 5, 2011 7:06 PM

    I think you will have to go back to the original development system. The versions will be there.
    Rob

  • How to recover to keep tablespaces working after datafile deleted on OS

    hi,
    given situation like this :
    1. OS HPUX 11i
    2. Oracle 9.2 or 10g
    3. tablespace AAA have a datafile AAA.dbf
    4. AAA.dbf has been deleted by a guy on OS by accident
    5. it's a production database , i have other copy of product running elsewhere
    6. we can forget about the data on this tablespace , just wanna make sure new data will still be inserted
    I know there is a magic way involving file descritpor to recovery the file on OS if it was still opened by the process
    seems it only works on linux or solaris , since HPUX don't have /proc
    here is what i had done ,
    1. offline drop the tablespace
    2. export tablespace AAA from other DB without data but everything else
    3. import them into DB without AAA now
    only problem seems application couldn't insert into the tables ,Object priveledge not granted
    i'd checked the export file , those object grant SQL are right there , i just don't know why import hasn't worked
    so my question is
    if it were you ,
    1.do you have any better idea of how to recover
    2.if you any dirty and fast way of recovery File on HP box , appreciate that too
    3.can you image why import doesn't seems getting priveledge imported ? my DB version 9.2.0.4
    many thanks
    br/ricky

    thanks , aman ,lenord and you all
    looks like i'm the sinful :)
    to clear it up ... it's not me who did it , one of our guys , same thing ,hum ~~
    he deleted the backup , cause it's full and auto backup is not ongoing , and he's trying to make things right
    he deleted the datafile , cause i told him to rename the file to another space , coz vgdb is full , screw up that too ..
    yeah , it'a real production database ~~ , so ,if anybody learn somethings on this , credit on me , :)
    the version is 9.2.0.4 , but gonna move to 10g soonor or later , so put it there , to see if in 10g , we can do better ..
    tablespace created like five years ago , so , apply all archive since would be crazy ~
    this database have 500 Tablespaces , and thoudsands of tables , and the one lost is a important one ,
    but data in it , we can bear loss
    what i do , is offline drop the tablespace , and import the tablespace without data from other production DB ...
    only it didn't work out so well with object grant , and application still not inserting ...
    why i post it here , is i wanna learn better ways in this kind of situations ...
    i thought my way is not good enough
    anway , i'll look at all your suggestions
    thanks
    br/ricky
    Edited by: zs_hzh on Sep 15, 2008 10:12 PM

Maybe you are looking for