Bugra Canbakal's Oracle Blog

  • Home
  • Contact
  • SITE MAP
You are here: Home / Oracle / RMAN / Flashback database

Flashback database

12:04 PM By Bugra Canbakal 4 Comments

1.PURPOSE AND SCOPE

It is posible to fix the logical errors, with using flashback database technology but for sure time period of this kind of operations depends of flashback time of database.While using flashback technology we can use time,log sequence or SCN.

P.S: Disk failure and deletion of datafile/redo/control file  cant be restored with technology.

2.PRACTICE

2.1. We are going to connect to closed db and open flashback option.

[oracle@sb trace]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Fri Jan 18 10:21:38 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 4.0353E+10 bytes
Fixed Size            2235176 bytes
Variable Size         2.1072E+10 bytes
Database Buffers     1.9193E+10 bytes
Redo Buffers           85233664 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.

2.2.   First of all we need to check Db_flashback_retention_target parameter , it will show us flashback time ,default of this parameter is  1140 minute. I am going to set it to 2 days.

SQL> show parameter flashback

NAME                                 TYPE             VALUE
------------------------------------ ---------------- --------------
db_flashback_retention_target         integer         1440

SQL> alter system set db_flashback_retention_target=2880;

System altered.

SQL> alter database open;

Database altered.

2.3.  I a going to create a dummy table with 1000 row.

 CREATE TABLE bcanbakal.table_x 
as select * from dba_objects where rownum < 1001;    Table created. SQL> select count(1) from bcanbakal.table_x;

  COUNT(1)
----------
      1000

2.4. For flashback operation i am going to SCN number of DB.Thats the reason first of all i am going to check SCN number of db ,after of it going to truncate table.

SQL> select a.oldest_flashback_scn,(select scn_to_timestamp(a.oldest_flashback_scn) from dual) oldest_flashback_time,(select 'Current scn: '|| current_scn||' .Current scn to date: '|| scn_to_timestamp(current_scn) from v$database) current_scn,a.retention_target,a.flashback_size,a.estimated_flashback_size from v$flashback_database_log a;

OLDEST_FLASHBACK_SCN     OLDEST_FLASHBACK_TIME                 CURRENT_SCN                                                                       RETENTION_TARGET   FLASHBACK_SIZE  ESTIMATED_FLASHBACK_SIZE
--------------------     ----------------------------------   --------------------------------------------------------------                    ----------------    --------------  ------------------------
         4363163         30-OCT-12 11.03.32.000000000 AM         Current scn: 5243411 .Current scn to date: 18-JAN-13 11.03.47.000000000 AM         2880            100687872       5256462336     

SQL> truncate table bcanbakal.table_x;

Table truncated.      

SQL> select count(1) from bcanbakal.table_x;

  COUNT(1)
----------
     0

2.5.  And now i am going to close database and use flashback technology to restore my table using SCN.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 4.0353E+10 bytes
Fixed Size            2235176 bytes
Variable Size         2.1072E+10 bytes
Database Buffers     1.9193E+10 bytes
Redo Buffers           85233664 bytes
Database mounted.
SQL> flashback database to scn 5243411;

Flashback complete.

2.6. We need to open database with resetlog option.It is wise to take full backup after using resetlog option.

SQL> alter database open resetlogs;

Database altered.

2.7.  Now lets check the table.

SQL> select count(1) from bcanbakal.table_x;

  COUNT(1)
----------
      1000

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on X (Opens in new window) X

Filed Under: RMAN, Single Node Tagged With: flashback, oracle flashback, resetlogs

Comments

  1. halil says

    Sunday January 20th, 2013 at 02:20 PM

    Merhaba Bugra Bey,
    Güzel bir blog ve çok güzel bir paylaşım teşekkürler öncelikle.
    Merak ettiğim konu flashback özelliğinin çökme ihtimali.Sistem ne kadarlık bir flashback’e izin verir acaba?Elbette disk ve diğer donanımsal özelliklere bağlıdır bu süre fakat demek istediğim Oracle tarafından önerilen bir limit var mı?Biliyor musunuz?
    Teşekkürler.

  2. Bugra Canbakal says

    Monday January 21st, 2013 at 08:16 AM

    Merhaba Hail bey blogu beyendiğinize sevindim.
    Oracle tarafından önerilen bir süre yok ama benim önereceğim 1-1,5 gün (gelen transectionve grown rate göre bu zaman değişebilir). Flashback teknolojisi db deki sıkıntılı durumlarda ve test amaçlı yük basılması durumlarında kullanılmakta asıl amacı ise rman recoverdan daha hızlı bir şekilde point in time recovery yapabilmek. Eğer zaman dilimini geniş tutarsak flashback esnekliğini kaybederiz.Bu tarz durumlarda rmanden recovery yapmak daha mantıklı olacaktır

  3. Manoj Mishra says

    Monday July 8th, 2019 at 02:32 PM

    Amazing post, every post is outstanding. Easily described each and every steps with query.

  4. Bugra Canbakal says

    Thursday February 13th, 2020 at 01:19 AM

    Glad to help!

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About Me



Language:

  • English
  • Turkish

Categories

  • Oracle
    • RAC – Real Application Cluster
    • RMAN
    • Single Node
    • Standby – Dataguard
  • OS
    • Linux

Blogroll

  • Emre Baransel
  • Gökhan Atıl
  • H. Tonguc Yılmaz
  • Kamil Türkyılmaz
  • Tanel Poder
  • Turkce Oracle
  • Turkish Oracle User Group
  • Uwe Hesse
  • Zekeriya Beşiroğlu

Archives

  • April 2014
  • March 2014
  • August 2013
  • June 2013
  • March 2013
  • January 2013
  • December 2012
  • November 2012
  • July 2012
  • June 2012
  • May 2012
  • January 2012
  • November 2011
  • October 2011
  • August 2011
  • July 2011
  • June 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • June 2010
OCP
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

[footer_backtotop]

Copyright © 2010-2014 Bugra Canbakal. All rights reserved.