DBA Hub

📋Steps in this guide1/2

Important Flashback Commands

P.S. Database should be in archive log mode.

oracle configurationintermediate
by OracleDba
14 views
1

Overview

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
alter system set db_recovery_file_dest_size=10G scope=both;

alter system set db_recovery_file_dest='/dumparea/FRA/D2PMS3' scope=both;

alter database flashback on;

select flashback_on from v$database;

alter database flashback off;

Flashback To (Time) :
select to_char(oldest_flashback_time,’dd-mon-yyyy hh24:mi:ss’) “Oldest Flashback Time”
from v$flashback_database_log;

Flashback To (SCN) :
col oldest_flashback_scn format 99999999999999999
select oldest_flashback_scn from v$flashback_database_log;

## First we need to check whether the table name exists in recyclebin or not:

SELECT object_name, original_name, createtime FROM recyclebin where original_name='EMP';

## Now restore the table with same name:
FLASHBACK TABLE emp TO BEFORE DROP;

## Restore that table with a new name:

FLASHBACK TABLE emp TO BEFORE DROP
RENAME TO emp1;

SELECT * FROM V$FLASH_RECOVERY_AREA_USAGE;
2

Section 2

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
shutdown immediate;
startup mount;

FLASHBACK DATABASE TO SCN 202381; ## this is for particular scn

FLASHBACK DATABASE TO TIMESTAMP (SYSDATE-1/24); ## This is for flashback to last one hour

FLASHBACK DATABASE TO TIMESTAMP to_timestamp('2023-08-17 16:00:00', 'YYYY-MM-DD HH24:MI:SS'); ## This is to specific timestamp.

alter database open resetlogs;

SELECT * FROM PDBUSER.EMP AS OF TIMESTAMP
TO_TIMESTAMP('2023-08-17 10:00:00', 'YYYY-MM-DD HH:MI:SS');


SELECT * FROM PDBUSER.EMP AS OF TIMESTAMP SYSDATE -1/24;

Follow the steps for flashback database to a guaranteed restore point;

1. Fetch the restore point name:

SQL> select NAME,time from v$restore_point;

NAME TIME
-------------------------------- -----------------------------------------------
FLASHBACK_PRIM 17-AUG-23 03.41.33.000000000 PM

2. Shutdown database and start db in Mount stage:

shutdown immediate;
startup mount;

3. flashback db to restore point:

flashback database to restore point FLASHBACK_PRIM;

4. Open database with resetlog:

alter database open resetlogs;

drop restore point FLASHBACK_PRIM;

create restore point FLASHBACK_PRIM guarantee flashback database;

## From SQL prompt:
SQL>Select * from v$restore_points:

## From RMAN prompt:
RMAN>LIST RESTORE POINT ALL;

Comments (0)

Please to add comments

No comments yet. Be the first to comment!