Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

We're approaching the end of 2012 and I still find myself relying on database exports to maintain the ability to do row level restore operations. While this is a proven method, it sure would be nice to get rid of all the export operations hogging database resources a significant number of hours each day.

A typical scenario would be that a customer accidentally deletes a project or document from an authoring system. To fix this I will need to locate and put back those deleted rows.

I'll pull up a database dump of the customer's schema from a date before the accidental delete, import the data to a new schema. Now I can identify the lost data, and select it back into the production schema.

I realize that you can do this directly with flash recovery, but there's a limit to how much data we can keep in the fast recovery area, and customers tend to not always figure out their mistakes within the allotted time.

Is there a good way to accomplish these kinds of tasks with the use of Oracle RMAN?

share|improve this question
1  
There's no nice way of doing this with rman. You'd have to do a point in time table space recovery to a different database, then work from that. Sounds like you'd be better off putting DELETE triggers on the affected tables that move the rows to archive tables, or re-architect the app to use is_deleted (or similar) flags, rather than actually deleting the rows. Delete triggers are probably easier, as they'd be transparent to the application. –  Phil Oct 29 '12 at 13:21
    
As an alternative to manually writing triggers a flashback archive does the same thing - especially on 11.2 –  a_horse_with_no_name Oct 29 '12 at 15:02

2 Answers 2

up vote 3 down vote accepted

The answer to your question is no, however....

It sounds like a flashback query is what you need. Query the data as of a time when it existed and when it returns the correct data, insert it into the current table. This solution does require space in the UNDO tablespace sufficient to meet your UNDO_RETENTION requirements. It also doesn't use RMAN, but is significantly simpler than importing the entire schema.

INSERT INTO T1 (
   SELECT * FROM T1 AS OF TIMESTAMP sysdate-1 
   WHERE MyDateColumn = to_date('05/25/2011','MM/DD/YYYY')
);
share|improve this answer
    
Whilst this is true, it won't solve the problem if the database is very busy (hence requiring a massive undotbs to satisfy the retention target) and the recovery operations are performed some time after the rows are deleted. Having said that, you did mention that in your answer :) –  Phil Oct 29 '12 at 13:58
    
Indeed, I would guess it won't accomplish the goal of eliminating the export, but even if it can only be used to replace a small number of imports due to space limitations, the time savings from not having to do the import would be worth it. –  Leigh Riffel Oct 29 '12 at 14:05
1  
I'm a little confused. Is flashback data stored in the fast recovery area, or does it live in the undo tablespace? The UNDO_RETENTION parameter is mentioned, but I thought that was related to retention of transaction rollback/undo segments. –  Roy Oct 30 '12 at 15:30
1  
Oracle uses Flashback to describe several very different features, some of which use the Flash(Fast) Recovery Area. For example, Flashback Database does, but Flashback Drop and Flashback Query do not. –  Leigh Riffel Oct 30 '12 at 15:57
1  
You are correct that UNDO is used to maintain the unchanged version of changed blocks for in progress transactions, but Oracle designed their Flashback Query feature to take advantage of retaining the data longer. See docs.oracle.com/cd/E11882_01/server.112/e25494/… and docs.oracle.com/cd/E11882_01/appdev.112/e25518/…. This is a feature unique to Oracle - dba.stackexchange.com/questions/359/…. –  Leigh Riffel Oct 30 '12 at 15:57

Your requirements look like a good case for Oracle's Flashback Data Archive (Total Recall) feature.

Disclaimer: I haven't used this feature yet.

The description reads:

A Flashback Data Archive provides the ability to track and store transactional changes to a table over its lifetime. A Flashback Data Archive is useful for compliance with record stage policies and audit reports.

You can enable it at the table level. You can specify an undo retention ; although I can't find the limit it is probably larger than you need since the goal is to keep records for legal purposes.

There is an example of a scenario that might apply to your specific case: Using Flashback Data Archive to Recover Data.

Oracle Total Recall is part of the Advanced Compression Option, available on the enterprise edition.

share|improve this answer
    
@mat thanks for the clarification –  Vincent Malgrat Oct 30 '12 at 12:51
    
Thanks for the tip, although with a list price of $11,500 per CPU licence, I don't think a little backup/restore convenience alone can defend the cost of Advanced Compression Option. –  Roy Oct 30 '12 at 15:38
    
@Roy agreed, expensive for anecdotal use, but might be interesting to record all activity over a sufficiently large number of tables. –  Vincent Malgrat Oct 30 '12 at 15:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.