Showing posts with label Flashback. Show all posts
Showing posts with label Flashback. Show all posts

Monday, December 5, 2016

How to perform flashback table forward and backward

CREATE TABLE TEST_FLASH(ID NUMBER);

ALTER TABLE TEST_FLASH ENABLE ROW MOVEMENT;

TRUNCATE TABLE TEST_FLASH;

INSERT INTO TEST_FLASH
SELECT LEVEL FROM DUAL CONNECT BY LEVEL<10000;

SELECT CURRENT_SCN FROM V$DATABASE;-- 63441120

INSERT INTO TEST_FLASH
SELECT LEVEL+10000 FROM DUAL CONNECT BY LEVEL<10000;

SELECT CURRENT_SCN FROM V$DATABASE;-- 63441184

SELECT COUNT(*) FROM TEST_FLASH; -- 19998

FLASHBACK TABLE TEST_FLASH to scn 63441120;

SELECT COUNT(*) FROM TEST_FLASH; -- 9999

FLASHBACK TABLE TEST_FLASH to scn 63441184;

SELECT COUNT(*) FROM TEST_FLASH; -- 19998

Tuesday, November 22, 2016

How to perform flashback database in RAC Database.

bash-4.3$ srvctl stop database -d dcdbrac

bash-4.3$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 22 07:15:20 2016

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

Connected to an idle instance.

SQL> STARTUP MOUNT EXCLUSIVE;
ORACLE instance started.

Total System Global Area 6.3069E+10 bytes
Fixed Size                  2393728 bytes
Variable Size            9059699072 bytes
Database Buffers         5.3989E+10 bytes
Redo Buffers               18116608 bytes
Database mounted.
SQL> FLASHBACK DATABASE TO TIMESTAMP SYSDATE-(1/8);


Flashback complete.

SQL> SQL>
SQL>
SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Data Mining, Oracle Database Vault and Real Application Testing options
bash-4.3$ srvctl status database -d dcdbrac
Instance dcdbrac1 is running on node dcdbrac01
Instance dcdbrac2 is not running on node dcdbrac02
bash-4.3$ srvctl stop instance -d dcdbrac -i dcdbrac1
bash-4.3$ srvctl start database -d dcdbrac
bash-4.3$

Monday, November 21, 2016

Enable Flashback in oracle RAC database


bash-4.3$ srvctl stop database -d dcdbrac
bash-4.3$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 22 00:52:44 2016

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

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 6.3069E+10 bytes
Fixed Size                  2393728 bytes
Variable Size            9059699072 bytes
Database Buffers         5.3989E+10 bytes
Redo Buffers               18116608 bytes
Database mounted.
SQL> alter database flashback on;

Database altered.

SQL> show parameter DB_FLASHBACK_RETENTION_TARGET

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target        integer     1440
SQL> alter database open;

Database altered.

SQL> select flashback_on  from v$database;

FLASHBACK_ON
------------------
YES

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Data Mining, Oracle Database Vault and Real Application Testing options
bash-4.3$
bash-4.3$ srvctl stop instance -d dcdbrac -i dcdbrac1
bash-4.3$ srvctl start database -d dcdbrac
bash-4.3$

Friday, December 12, 2014

ORA-38706: Cannot turn on FLASHBACK DATABASE logging.

SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38707: Media recovery is not enabled.

Cause : For enable flashback database must be archive mode. To resolve this error enable archive log mode.

SQL>
SQL> STARTUP MOUNT;
ORACLE instance started.

Total System Global Area  630501376 bytes
Fixed Size                  2215984 bytes
Variable Size             381685712 bytes
Database Buffers          243269632 bytes
Redo Buffers                3330048 bytes
Database mounted.

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/oradata/archive
Oldest online log sequence     434
Current log sequence           436
SQL> alter database archivelog;

Database altered.

SQL> alter database flashback on;

Database altered.

SQL>