Sunday, November 21, 2010

Enabling ARCHIVELOG Mode

SQL> SELECT LOG_MODE FROM SYS.V$DATABASE;

LOG_MODE
------------
NOARCHIVELOG

We can use a database alter statement or edit the pfile in either $ORACLE_BASE/admin/SID/pfile or $ORACLE_HOME/admin/SID/pfile. Add the following lines to the end of the file:

############################
# Archive Log Destinations
############################
log_archive_dest_1='location=/u02/oradata/cuddle/archive'
log_archive_start=TRUE

Startup the database in mount mode and put it in archivelog mode.

[oracle@vixen pfile]$sqlplus sys/passwd as sysdba;
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Oct 15 16:00:58 2004
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup mount
ORACLE instance started.
Total System Global Area 184549376 bytes
Fixed Size 1300928 bytes
Variable Size 157820480 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.

SQL> alter database archivelog;
Database altered.

SQL> alter database open;
Database altered.

How to enable flashback database in Oracle

-- Set flashback database parameters


alter system set db_recovery_file_dest_size=10G;

alter system set db_recovery_file_dest='/dir/fra';

-- value in minutes

alter system set db_flashback_retention_target=2160;

-- Turn flashback on for the database

startup mount;

alter database flashback on;

alter database open;

-- Check if flashback is enabled

select flashback_on from v$database;

select * from v$flashback_database_log;
--
--
-- To create a guaranteed restore point

create restore point RESTORE_POINT guarantee flashback database;

select NAME, SCN, TIME from V$RESTORE_POINT;

-- To flashback the database to specific time

flashback database to timestamp to_timestamp('dd/mm/ccyy HH24:MI:SS', 'DD/MM/YYYY

HH24:MI:SS');

-- To drop a restore point

select NAME, SCN, TIME from V$RESTORE_POINT;

drop restore point RESTORE_POINT;