Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum DBA Videos
internet.com

» Database Journal Home
» DBA Videos
» Database Articles
» Database Tutorials
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed



follow us on Twitter

Marketplace Partners
Be a Marketplace Partner

internet.commerce
Be a Commerce Partner


















Mariposa Bot Shipped With Vodafone Smartphone

IT Job Market Heating Up: Report

Bing Makes Strides But Momentum Stalls

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Database Journal | DBA Support | SQLCourse | SQLCourse2







Senior Systems Administrator – Windows (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

Oracle

May 9, 2003

Recovering Accidentally Lost Data Using Oracle's Flashback Query

by Sreeram Surapaneni

Illustrations:

Having discussed the concepts behind the Flashback Query, let us now examine how it can be used in a real world environment. Let us take the example of an email-company where the set of email addresses was accidently deleted by the DBA from users table at 9:05AM. This mistake was later discovered at 11:30AM. If the company decides to rollback the database just prior to 9:05 AM, when the error occurred, in order to "recover" the deleted data, it would not only loose all subsequent transactions but also the system will be unavailable for the duration of the recovery. Clearly, this is not a solution for the service- company since it forces the company to compromise the system availability to serve the existing users in the system. Flashback query makes it possible for the company to correct the mistake without effecting normal operations as illustrated below.

Example 1
Using "AS OF" clause:

INSERT INTO USERS 
	(SELECT  * FROM USERS AS OF TIMESTAMP
	TO_TIMESTAMP ('22-APR-03 9:04:58','DD-MON-YY HH24: MI: SS')
	MINUS

	SELECT * FROM USERS);

Using "DBMS_FLASHBACK utility":

DECLARE
  CURSOR c IS
    SELECT *
    FROM   users;
v_rec  c%ROWTYPE;
BEGIN
DBMS_FLASHBACK.ENABLE_AT_TIME ('22-MAR-03 09:04:58');
  OPEN c;
DBMS_FLASHBACK.DISABLE;
LOOP 
    FETCH c INTO v_row; 
    EXIT WHEN c%NOTFOUND; 
    INSERT INTO users VALUES
    (v_rec.user_id, v_rec.first_name, 
     v_rec.last_name, v_rec.email, 
     v_rec.phone_number, v_rec.address,
     ); 
  END LOOP; 
  CLOSE c;
  COMMIT;
END;


Go to page: Prev  1  2  3  Next  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

Oracle Archives








Latest Forum Threads
Oracle Forum
Topic By Replies Updated
getting first date and last date of previous month in oracle Osho4U 13 March 19th, 02:50 AM
Free ERD program with import option ? tenamatt 1 February 26th, 01:39 PM
Record Select inet 1 February 26th, 01:38 PM
Rownum inet 1 February 18th, 10:01 AM









The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers