I dropped a table in Oracle, how can I retrieve it from the undo tablespace?

user2836455 picture user2836455 · Oct 1, 2013 · Viewed 8.1k times · Source

I accidentally dropped a fairly large table -- recycling bin is not enabled. I'm fairly certain the data still exists in the UNDO tablespace, but I'm not sure how to get it out. I recreated the table exactly as it was before it was dropped -- the structure is exactly the same. However, when I attempt to flashback the table, I get this error:

flashback table tablex to timestamp (systimestamp - interval '120' minute);
Error: 01466
DBD::Oracle::db do failed: ORA-01466: unable to read data - table definition has changed

Any idea how I can overcome this error? From all of the searching I've done, it seems as if it believes the table is not structurally the same as when it was dropped.

Answer

Przemyslaw Kruglej picture Przemyslaw Kruglej · Oct 1, 2013

I think you should not recreate the table by yourself - it will be recreated for you by Oracle when you Flashback it, I recommend the following article: http://www.oracle-base.com/articles/10g/flashback-10g.php#flashback_table

Example:

CREATE TABLE flashback_table_test (
  id NUMBER CONSTRAINT pk_flashback_table_test PRIMARY KEY
);

DROP TABLE flashback_table_test;
FLASHBACK TABLE flashback_table_test TO BEFORE DROP;

I think you will need to flash it back using some SCN number prior to the number when you manually recreated the table.