Sunteți pe pagina 1din 11

CONTROL FILE

A Control File is a small binary file that stores information needed to startup an Oracle database
and to operate the database .

Every Oracle Database has a control file, which is a small binary file that records the physical
structure of the database. The control file includes:
 The database name
 Names and locations of associated data files and redo log files
 The timestamp of the database creation
 The current log sequence number
 Checkpoint information
The control file must be available for writing by the Oracle Database server whenever the
database is open. Without the control file, the database cannot be mounted and recovery is
difficult.

Managing Control Files


Control files are automatically created with the Oracle Managed Files (OMF) approach during
database creation
DB_CREATE_FILE_DEST parameter : defines the location of the default file system directory

DB_CREATE_ONLINE_LOG_DEST_n : defines the location of the default file system


directory for online redo log files

Obtaining information about control files


We should get information about control files in our Oracle database.
Control file name and Availability
V$CONTROLFILE view: has two columns --STATUS & NAME
STATUS: Displays invalid if the control file name cannot be determined; otherwise NULL
NAME: Gives the path location of the file on your host machine as control file name

Important control file contents


CONTROLFILE_TYPE: The section type in the control file.

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 1


CONTROLFILE_CREATED: Indicates when the control file was created.
CONTROLFILE_SEQUENCE #: Current sequence number of the control file.
CONTROLFILE_TIME: The previous time the control file was updated.

Multiplexing Control Files


Control files should be multiplexed – this means that more than one identical copy is kept
and each copy is stored to a separate, physical disk drive– of course your Server must have
multiple disk drives in order to do this. Even if only one disk drive is available, you should still
multiplex the control files.
o This eliminates the need to use database recovery if a copy of a control file is destroyed in a
disk crash or through accidental deletion.
o You can keep up to eight copies of control files – the Oracle Server will automatically update
all control files specified in the initialization parameter file to a limit of eight.
o More than one copy of a control file can be created by specifying the location and file name
in the CONTROL_FILES parameter of the PFILEwhen the database is created.
o During database operation, only the first control file listed in
the CONTROL_FILES parameter is read, but all control files listed are written to in order
to maintain consistency.
o One approach to multiplexing control files is to store a copy to every disk drive used to
multiplex redo log members of redo log groups.

*****

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 2


MAINTAINING REDO LOG FILES

1. The Purpose and structure of online redo logs


2. Controlling log switches and checkpoints
3. Multiplexing and Maintaining redo log files
4. Managing redo logs with OMF

Redo logs are disk resources that stores data changes made by users on Oracle.

1. The Purpose and structure of online redo logs


Oracle uses redo logs to track data changes users make to database. This entry is placed in redo
log buffer of SGA. The online redo log of a database consists of two or more online redo log
files. LGWR writes to online redo log files in a circular fashion. When the current online redo
log file fills, LGWR begins writing to the next available online redo log file. When the last
available online redo log file is filled, LGWR returns to the first online redo log file and writes to
it, starting the cycle again. Figure illustrates the circular writing of the online redo log file. The
numbers next to each line indicate the sequence in which LGWR writes to each online redo log
file.

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 3


2. Controlling log switches and checkpoints

A log switch is the point at which Oracle ends writing to one online redo log file and begins
writing to another. Normally, a log switch occurs when the current online redo log file is
completely filled and writing must continue to the next online redo log file.

Oracle assigns each online redo log file a new log sequence number every time that a log switch
occurs and LGWR begins writing to it. If Oracle archives online redo log files, the archived log
retains its log sequence number. The online redo log file that is cycled back for use is given the
next available log sequence number.
Each online or archived redo log file is uniquely identified by its log sequence number. During
crash, instance, or media recovery, Oracle properly applies redo log files in ascending order by
using the log sequence number of necessary archived and online redo log files.

3. Multiplexing and Maintaining redo log files

To protect against a failure involving the redo log itself, Oracle Database allows a multiplexed
redo log, meaning that two or more identical copies of the redo log can be automatically
maintained in separate locations. For the most benefit, these locations should be on separate
disks. Even if all copies of the redo log are on the same disk, however, the redundancy can help
protect against I/O errors, file corruption, and so on. When redo log files are multiplexed, LGWR
concurrently writes the same redo log information to multiple identical redo log files, thereby
eliminating a single point of redo log failure.
Multiplexing is implemented by creating groups of redo log files. A group consists of a redo log
file and its multiplexed copies. Each identical copy is said to be a member of the group. Each
redo log group is defined by a number, such as group 1, group 2, and so on.

Creating Online Redo Log Groups

To create a new group of online redo log files, use the SQL statement ALTER DATABASE with
the ADD LOGFILE clause.

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 4


Renaming Online Redo Log Members

You can use operating system commands to relocate online redo logs, then use the ALTER
DATABASE statement to make their new names (locations) known to the database.

4. Managing redo logs with OMF

Managing Oracle managed redo log files is exactly the same as managing Oracle control files.
Both uses the same init.ora parameters. Redo logs are created when we create the database. We
can create new redo logs by alter database add logfile group command. The default size of
Oracle managed redo log file is 100 MB. This value can be overridden by specifying the size of
the redo log files ( during create database or alter database commands)
******

Describing the Logical structure of the Database

The three important units in logical Oracle disk resources are

1. Table spaces
2. Segments
3. Extends

A tablespace is a logical database structure that is designed to store other logical database
structures. Oracle sees tablespace as a large area of space into which Oracle can place new
objects. Space in tables is allocated to segments

A segment is an allocation of space used to store data of a table, index and undo segments or
temporary objects. When the database object runs out of space in its segment and needs to add
more data, Oracle allocates more space from an extent.

An extent is similar to a segment in that extent stores information corresponding to a table,


index, undo segment, or temporary object.

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 5


Logical Database structures
Logical structures include tablespaces, schema objects, data blocks, extents and segments.

Tablespaces
Database is logically divided into one or more tablespaces. Each tablespace creates one or more
datafiles to physically store data.

Schema objects
Schema objects are the structure that represents database's data. Schema objects include
structures such as tables, views, sequences, stored procedures, indexes, synonyms, clusters and
database links.

Data Blocks
Data block represents specific number of bytes of physical database space on disk.

Extents
An extent represents continuous data blocks that are used to store specific data information.

Segments
A segment is a set of extents allocated for a certain logical structure.

Physical database structure


The physical database structure comprises of datafiles, redo log files and control files

Datafiles
Datafiles contain database's data. The data of logical data structures such as tables and indexes is
stored in datafiles of the database. One or more datafiles form a logical unit of database storage
called a tablespace.

Redo log files


The purpose of these files is to record all changes made to data. These files protect database
against failures.

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 6


Control files
Control files contain entries such as database name, name and location of datafiles and redo log
files and time stamp of database creation

How Oracle handles space management in tablespaces


Free space management is an important task of Oracle without which Oracle cannot do where to
put tables , indexes when you want to create or modify them.
Dictionary Managed TableSpaces (DMT)→ rely on data dictionary tables in the SYSTEM table
spaces to track free space utilization.

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 7


Locally Managed Tablespaces→ A Locally Managed Tablespace (LMT) is a tablespace that
manages its own extents maintaining a bitmap in each data file to keep track of the free or used
status of blocks in that data file.

Permanent tablespaces Vs Temporary tablespaces


There are three types of tablespaces: (1) permanent, (2) undo, and (3) temporary.
Permanent – These tablespaces store objects in segments that are permanent – that persist
beyond the duration of a session or transaction.
Undo – These tablespaces store segments that may be retained beyond a transaction, but are
basically used to:
o Provide read consistency for SELECT statements that access tables that have rows that are in
the process of being modified.
o Provide the ability to rollback a transaction that fails to commit.
Temporary – This tablespace stores segments that are transient and only exist for the duration of
a session or a transaction. Mostly, a temporary tablespace stores rows for sort and join
operations.
-----------------------------
CREATING TABLESPACES

Tablespaces are the bridge between certain physical and logical components of the Oracle
database.Tablespaces are where you store Oracle database objects such as tables, indexes and
rollback segments. You can think of a tablespace like a shared disk drive in Windows.
The following tablespaces are to be created
SYSTEM: The SYSTEM tablespace is the first tablespace created at database creation. It is
managed as any other tablespace, but requires a higher level of privilege and is restricted in some
ways.
DATA: A DATA table space is used to house the table data
INDEX: used to house indexes separate from other type of objects.
Undo tablespace, which is specifically designed to contain undo records. These are records
generated by the database that are used to rollback, or undo, changes to the database for
recovery, read consistency, or as requested by a ROLLBACK statement

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 8


TEMP : Used to hold temporary segments
TOOLS: This table space is used to house objects that support administrative or other tools we
use like OEM.
Creating permanent/temporary tablespace/undo tablespaces
Use the CREATE TABLESPACE statement to create a tablespace, which is an allocation of
space in the database that can contain schema objects.

 A permanent tablespace contains persistent schema objects. Objects in permanent


tablespaces are stored in datafiles.
 An undo tablespace is a type of permanent tablespace used by Oracle Database to
manage undo data if you are running your database in automatic undo management
mode. Oracle strongly recommends that you use automatic undo management mode
rather than using rollback segments for undo. The Undo tablespace is used for
automatic undo management. More than one UNDO tablespace can exist, but only
one can be active at a time.
 A temporary tablespace contains schema objects only for the duration of a session.
Objects in temporary tablespaces are stored in tempfiles. A TEMPORARY
tablespace is used to manage space for sort operations. Sort operations generate
segments, sometimes large segments or lots of them depending on the sort required
to satisfy the specification in a SELECT statement's WHERE clause.

Default storage options


The default storage clause defines the storage options that will be applied to newly created
database objects if the create statement does not have storage parameters defined for it. The
initial and next options specify the size of the object’s initial segment and next allocated extent.
The minextents and maxextents specify the minimum and maximum number of extents the
object can allocate in the table space.
pctincrease→ specifies the percentage in increase in the amount of table space allocated for the
next extent in the object.

-----------------------

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 9


Storage Structures and Relationships

PART-A QUESTIONS
1. What are the three important units in logical Oracle disk resource?
The three important units in logical Oracle disk resources are
1. Table spaces
2. Segments
3. Extends

2. What are Tablespaces?


A tablespace is a logical database structure that is designed to store other logical database
structures. Oracle sees tablespace as a large area of space into which Oracle can place new
objects. Space in tables is allocated to segments

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 10


3. Explain the following: i. DBA_FREE_SPACE_COALESCED ii.DBA_EXTENTS

4. What are the uses of UNDO segments?

The key objective of UNDO segments is to support: Transaction rollback. When a ROLLBACK
statement is issued inside a transaction in order to cancel the changes done to the database, then
the UNDO data records are used to reverse those changes by writing them back to the underlying table
and index data blocks.

5. State The Purpose and structure of online redo logs.

Oracle uses redo logs to track data changes users make to database. This entry is placed in redo
log buffer of SGA. The online redo log of a database consists of two or more online redo log
files. LGWR writes to online redo log files in a circular fashion. When the current online redo
log file fills, LGWR begins writing to the next available online redo log file. When the last
available online redo log file is filled, LGWR returns to the first online redo log file and writes to
it, starting the cycle again

PART-B QUESTIONS
1. What is a control file? Discuss about Managing Control Files and Multiplexing
Control Files.
2. Explain with a neat diagram the logical structure of the database.
3. Discuss in detail about maintaining redo log files
4. Discuss the importance of tablespaces in Oracle

5. Explain the following-

The Purpose and structure of online redo logs


Controlling log switches and checkpoints
Managing redo logs with OMF

PCA15E04 DATABASE ADMINISTRATION UNIT-2 Page 11

S-ar putea să vă placă și