Professional Documents
Culture Documents
LOG_MODE
------------
NOARCHIVELOG
Database altered.
Database altered.
LOG_MODE
------------
ARCHIVELOG
Page | 1
LOG FILES:
Every Oracle database must have at least 2 redo logfile groups. Oracle writes all statements
except, SELECT statement, to the logfiles. This is done because Oracle performs deferred batch
writes i.e. it does write changes to disk per statement instead it performs write in batches. So in
this case if a user updates a row, Oracle will change the row in db_buffer_cache and records the
statement in the logfile and give the message to the user that row is updated. Actually the row is
not yet written back to the datafile but still it give the message to the user that row is updated.
After 3 seconds the row is actually written to the datafile. This is known as deferred batch
writes.
Since Oracle defers writing to the datafile there is chance of power failure or system crash before
the row is written to the disk. That’s why Oracle writes the statement in redo logfile so that in
case of power failure or system crash oracle can re-execute the statements next time when you
open the database.
Note: You can add groups to a database up to the MAXLOGFILES setting you have specified at
the time of creating the database. If you want to change MAXLOGFILE setting you have to
create a new controlfile.
Note: You can add members to a group up to the MAXLOGMEMBERS setting you have
specified at the time of creating the database. If you want to change MAXLOGMEMBERS
setting you have create a new controlfile
Page | 2
SQL>alter database drop logfile member
‘/u01/oracle/ica/log11.ora’;
Note: When you drop logfiles the files are not deleted from the disk. You have to use O/S
command to delete the files from disk.
It is not possible to use both methods in a single instance simultaneous, but the method can
be switched, a procedure which requires the instance to be bounced.
• Undo Tablespace Creation
• Enabling Automatic Undo Management
• Maintenance
• Monitoring
Automatic undo management requires a locally managed undo tablespace to store undo
segments in. Undo tablespaces can be created during database creation or using the
CREATE UNDO TABLESPACE statement:
-- As part of database creation
CREATE DATABASE rbdb1
CONTROLFILE REUSE
...
UNDO TABLESPACE undotbs_01
DATAFILE 'C:\Oracle\Ordata\TSH1\undo0101.dbf'
SIZE 100M REUSE AUTOEXTEND ON;
Page | 3
Enabling Automatic Undo Management
Since the default undo management mode is MANUAL, the instance must be told to use
AUTO mode at instance startup. To do this the following initialization parameters can be set:
UNDO_MANAGEMENT = AUTO # Default is MANUAL
UNDO_TABLESPACE = undotbs_01 # The name of the undo tablespace.
UNDO_RETENTION = 900 # The time undo is retained.
# Default is 900 seconds.
UNDO_SUPPRESS_ERRORS = TRUE # Suppress errors when MANUAL undo admin
# SQL statements are issued.
Several of these parameters can be altered while the instance is up, but the
UNDO_MANAGEMENT parameter is static:
-- Dynamic Parameters.
ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS_02;
ALTER SYSTEM SET UNDO_RETENTION=5;
ALTER SYSTEM SET UNDO_SUPPRESS_ERRORS=FALSE;
-- Static Parameters.
ALTER SYSTEM SET UNDO_MANAGEMENT=AUTO SCOPE=SPFILE;
Maintenance
-- Add a datafile.
ALTER TABLESPACE undotbs_01
ADD DATAFILE 'C:\Oracle\Ordata\TSH1\undo0102.dbf'
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED;
Monitoring
Undo information can be queried using the following views:
V$UNDOSTAT
V$ROLLSTAT
V$TRANSACTION
DBA_UNDO_EXTENTS
Page | 4