Question

I have accdently deleted some rows in a table and did the commit too. Now I want to recover them.

The DB I'm using is Oracle 11g R2.

I used the following query to get deleted records:

SELECT * FROM MY_TABLE AS OF TIMESTAMP ('13-MAR-11 8:50:58','DD-MON-YY HH24: MI: SS')

But while executing it gives an error saying:

Error at Command Line:3 Column:75
Error report:
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 -  "missing right parenthesis"
*Cause:    
*Action:

But I couldn't figure the problem in this queury.

Can anyone pls help?

Was it helpful?

Solution

That requires an actual timestamp (or date), you're passing a pair of values.

Try:

SELECT * FROM MY_TABLE
AS OF TIMESTAMP TO_DATE('13-MAR-11 08:50:58','DD-MON-YY HH24:MI:SS')

(Your time format specifier isn't correct either and doesn't match your date string.)

OTHER TIPS

for example :

    SELECT * FROM EMP AS OF TIMESTAMP 
   TO_TIMESTAMP('2005-04-04 09:30:00', 'YYYY-MM-DD HH:MI:SS')
   WHERE name = 'JOHN';

But flashback query may fail with ORA-1555 , other option :

Logminer

if Oracle supplement log is enabled , you can get undo sql for your delete statement

-- switch again logfile to get a minimal redo activity alter system switch logfile;

-- mine the last written archived log 
exec dbms_logmnr.add_logfile('archivelog/redologfile', options =>dbms_logmnr.new); 
exec dbms_logmnr.start_logmnr(options => dbms_logmnr.dict_from_online_catalog); 
select operation, sql_redo from v$logmnr_contents where seg_name = 'EMP';

Oracle PRM-DUL

PRM-DUL will be last option. Even deleted row piece in Oracle block is always just marked row flag with deleted mask, the row piece still can be read via scan Oracle data block . PRM-DUL can scan the whole table , find out every record/row piece marked deleted and write out to flat file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top