Sie sind auf Seite 1von 18

CHAPTER 1.

ORACLE ARCHITECTURE
STRUCTURE
1.1

INTRODUCTION

1.2

AN OVERVIEW OF DATABASE AND INSTANCES

1.3

INTERNAL DATABASE STRUCUTRES

1.4

INTERNAL MEMORY STRUCTURES


1.4.1

Global Areas

1.4.2

Background Processes

1.5

EXTERNAL STRUCTRES

1.6

ARCHITECTURE OVERVIEW

1.7

EXERCICES

1.8

ANSWERS

1.1

INTRODUCTION
Development of Relational databases started in the early 70s. By 1980, relational

databases were the most spoken of RDBMSs. Along with the development of relational
databases, SQL also gained wide popularity.
For any RDBMS to be accepted as a full-fledged RDBMS, it has to follow the
twelve codds rules. There are number of products called RDBMSs attempting to meet
all the 12 codd's rules, but all the 12 rules are until now not been satisfied by any
RDBMS. ORACLE also, not 100% relational, since it does not obey all codds rules.
1.2 AN OVERVIEW OF DATABASES AND INSTANCES:
Two basic concepts have to be understood in order to make any sense out of the
ORACLE architecture: database and instance.

i. exe

Data bases: Database is a set of data. Since ORACLE is a RDBMS, data in the database
is stored in tables. ORACLE database stores its data in files. Internally there are database
structures that provide a logical mapping of data files, allowing different types of data to
be stored separately. These logical divisions are called Table spaces.
Table spaces: A table space is a logical division of a database. Each database has at least
one table space (called the SYSTEM Table Space). Other table spaces may be used to
group users or applications together for ease of maintenance and for performance
benefits. A table space can belong to only one database.
Files: Each table spaces is constituted of one or more files, called Data Files, on a disk.
A data file can belong to one and only one table space.
The relation ship among databases, table spaces and data files are illustrated
below in figure 1.1.
DATABASE:

TABLESPACE

SYSTEM
SYSTEM
Tablespce
Table Space

Second
Second
Tablespace
Table Space

Third
Third
Table
Tablespace
Space

DATAFILES
:

Figure 1.1 : Relationship between database, table space and Data files.

Instances:

In order to access the data in database, ORACLE uses a set of background

process that are shared by all users. In addition, there are memory structures that are used
to store most recently required data from database.
A database instance (also known as a Server) is a set of memory structures and
background processes that access a set of database files. The relationship between
instances and database is illustrated below in the fig 1.2.

INSTANCE 1
(SGA + Processes)

INSTANCE 2
(SGA + Processes)

DATABASE FILES

Figure 1.2: Relationship between Instances and database.


1.3 INTERNAL DATA BASE STRUCTURES:
ORACLE data base structures can be divided into 3 categories.

Those that are internal to database (such as tables).

Those that are internal to the memory areas.

Those that are external to database.

The elements that are internal to database include


Tables, columns, constraints and data types (including abstract
data types)
Users and Schemes

Indexes, Clusters and Hash clusters


Views
Sequences
Procedures, Functions, Packages and Triggers
Synonyms
Privileges and Roles
Database Links
Segments, Extents and Blocks
Rollback Segments
Table, columns and data types:

Tables are storage mechanism for data within an

ORACLE database. They contain a fixed set of columns. Each column has a name and
specific characteristics. The characteristic of a column is made up of 2 parts: Its data
type and its length. The ORACLE has a set of data type like NUMBER for numeric,
VARCHAR for variable length character strings, DATE for storing date in the form of
DD-MM-YY etc. In addition to the data types user can create his own abstract data types.
For example, he may create a data type that contains the multiple parts of a address
House-Number, Main, Cross, Extension, City, State etc - as single data type and can be
called by a name address which can be treated as a data type.
Constraints:

A table can have constraints placed upon it; when a constraint is

applied to a table, every row in the table must satisfy the conditions specified in the
constraint definition.
Constraints can be applied at the time of creating a table.
Example:
Create table EMPLOYEE
( emp_no

Number (10)

PRIMARY KEY,

name

Varchar2 (40) NOT NULL,

dept_no

Number (2)

DEFAULT 10,

salary

Number (7,2)

CHECK salary < 1000000,

soc_sec_no

Char(9)

UNIQUE );

In the above example, NOT NULL is a constraint applied to a name column. This
means that every rows that is stored in the table must have a value for that column; it
cannot be left NULL.
A column can have a default constraint (In above example column dept_no). This
constraint is used to insert value 10 when row is inserted with a NULL value to the
dept_no column.
The CHECK constraint is used to ensure that values in a specified column meet
a certain criterion (in the above example, salary columns value is less than 1000000).
The UNIQUE, is used to specify uniqueness for columns that should be unique
but are not part of the primary key. In the above example, every record in the table must
have a unique value for the column soc_sec_no.
Views:

Views are masks placed upon tables. Views appear to be a table containing

columns. Columns in views are found in one or more underlying tables. The view does
not use physical storage to store data.
Partitions:

Larger tables can be splited into smaller ones, these smaller tables are

called partitions.
Users:

Users own the database objects. When objects are created in database in

support of applications, they are created under user accounts.


Schemes:

A set of objects (such as table and views) owned by a user account is called

the Users Schema.


Indexes:
table.

An index is a database structure used by the server to quickly find a row in a

Clusters:

The tables that are frequently accessed together may be physically stored

together. To store them together, a cluster is created to hold the tables.


Sequences:

Sequences are used to simplify programming efforts by providing a

sequential list of unique numbers.


Procedures:

Procedure is a block of PL/SQL statements that is stored in a data

dictionary and is called by applications. Procedures allow you to store frequently used
application logic within the database. A procedure does not return any value to the
calling program.
Functions:

Functions like procedures, are blocks of code that are stored in the

database. Functions returns a value to calling program.


Packages:

Packages are used to arrange procedures and functions into logical

grouping. This helps to organize related procedures.


Triggers:

Triggers are procedures that are executed when a specified data base event

takes place against a specified table.


Synonyms:

Synonyms are used to provide pointers for tables, views, procedures,

functions, packages and sequences. They can point to objects within the local databases
or in remote database.
Privileges and Roles:

Privileges means Permission. Privileges need to be granted to

access an object owned by another account. Privileges need to be granted for nonowners. Roles or groups of privileges, can be used to simplify this process. Privileges can
be granted to a Role, and the Role in turn can be granted to multiple users.
Database links:
remote database.

Database links are created to specify access path to an object in a

Segments, Extents and Blocks: Segments are the physical counterparts to logical
database objects. Segments store data. Index segments, for example, store the data
associated with indexes. A segment is made up of sections called extents - contiguous
sets of ORACLE blocks.
Rollback segment: Rollback means getting previous image or state of the object.
ORACLE have a mechanism for reconstructing the Before image of data for
uncommitted transactions. ORACLE uses rollback segments within the database to
accomplish this.
1.4

INTERNAL MEMORY STRUCTURES:


There are two different types of memory structures that are used by ORACLE

database.

Global areas

Background Processes

1.4.1 GLOBAL AREAS:


Following are the global memory areas used by all ORACLE database users

System global areas (SGA).

Data block buffer cache.

Dictionary cache.

Redo log buffer.

Shared SQL pool.

Context areas.

Programmed global areas (PGA).

System Global areas:

SGA facilitates the transfer of the information between the

users. It also holds the most commonly requested structural information about the
database.
Data block buffer cache:

It is a cache memory in the SGA used to hold the data

blocks that are read from the data segments in database, such as tables, indexes and
clusters. Typically, the data block buffer cache is about 1 to 2% of the size of database.
Dictionary cache:

The information about database objects such as table descriptions,

user account data, data file names, segment names, etc. are stored in data dictionary
tables. These data dictionary tables are stored in cache memory called Directory Cache.
Redo Log buffer:

ORACLE maintains logs of all transactions against the database.

These transitions are recorded in files called Online Redo Log files. Redo entries
describes the changes that are made to the database. Redo entries are written to the
online redo log files.

Before being written to the online redo log files, however,

transactions are first recorded in the SGA in an area called Redo Log Buffer. The
database then periodically writes batches of redo entries to the online redo log files.
Library cache:

It contains information about statements that are run against the

database. While the data block buffer and directory cache enable sharing of structural
and data information between the users in the database, the library cache allows the
sharing of commonly used SQL statements.
Shared SQL pool:

It stores the data dictionary cache and the library cache. The

shared SQL pool contains the execution plan and parse tree for SQL statements run
against the database.
Context Areas:

Within the shared SQL areas, there are both public and private

areas. Every SQL statement issued by the user requires a private SQL area. Composition
of the SGA is shown in the figure 1.3.

DATA BLOCK
BUFFER

REDO LOG
BUFFER

DICTIONARY
CHACHE

SHARED SQL
POOL

Figure 1.3 : Composition of System Global Area.

Program Global Areas:

It is an area in memory that is used by a single ORACLE

user process. The memory in PGA is not shareable.


1.4.2

BACKGROUND PROCESS:
The relationships between databases physical and memory structures are

maintained and enforced by the background process. These processes are managed by the
database and require little administrative work.
The Relationships between the physical structures and memory structures in the
database along with the major background process are shown in the figure 1.4.

Memory:

PGA

Data
Buffer
Cache

Context
Areas

Dedicated or
Shared Server

Processes

Files

USER

Data
Files

Redo
Log
Buffers

PMON

DBWR

Control
Files

CKPT

Online
Redo
Logs

LGWR

SMON

ARCH

Archived
Redo
Logs

Figure 1.4: Physical, Memory, and Process structure in ORACLE.


Each background process and the role it plays in managing a database are
described below.
SMON:
SMON is a short form used for system monitor. When database is stored it
cleans up the database eliminating transactual objects that are no longer needed by the
system. It also performs instance recovery as needed.
PMON:
PMON is a short form used for Process Monitor. This process cleans up behind
failed user processes. It frees up the resources that the user was using. Its affects can be
processed holding a lock is killed; PMON is responsible for releasing the lock and
making it available to another user. Like SMON, PMON wakes up periodically to check
if it is needed.
DBWR:
It is a short form used for Data Base Writer. It is responsible for managing
contents of the data block buffer cache and dictionary cache. It reads the blocks from the
data files and stores them in the SGA. DBWR performs the batch writes of changed
blocks back to the data files.
LGWR:
It is a short form used for Log Writer. The LGWR background process manages
the writing of the contents of the Redo log buffer to the online redo log files. LGWR
write log entries to the online Redo Log files in batches. The Redo Log buffer entries
always contain the most up to date status of the database. LGWR is the only process that
writes to the online Redo Log files and the only one that directly reads the Redo Log
buffer during normal database operation.

CKPT:
It is a short form used for Checkpoints. Checkpoints help to reduce the amount of
the time needed to perform instance recovery. Checkpoints cause DBWR to write all the
blocks that have been modified since the last checkpoint to the data files and update the
data file header and control files to record the checkpoints.

Checkpoints occur

automatically when an online Redo Log file fills. CKPT is an optional background
process.
ARCH:
It is a short form used for Archiving Function. LGWR background process
writes to online Redo Log files in a cyclical fashion i.e. after filling the current log files,
it begins writing the next. Once the last online Redo Log file is filled, LGWR begins to
overwrite the contents of first redo log file.
When ORACLE is run in ARCHIEVE LOG mode, the database makes a copy of
each Redo Log file before overwriting it. The ARCH background process performs this
archiving function.
RECO:
It is a short form used for Recovery. The RECO background process is used to
resolve failures in distributed databases. RECO attempts to access databases involved
In-doubt distributed transactions and resolve the transactions.
SNPn:
It is a short form used for Snapshot. ORACLE's Snapshot refreshes and internal
job queue scheduling relay on background processes for their execution. These
background processes names start with the letters SNP and end with a number or letter.
LCKn:
It is a short form used for Locking. Multiple LCK processes, named LCK0
through LCK9, are used for inter instance locking when the ORACLE parallel server
option is used.

Dnnn:
It is a short form used for Dispatcher Processes. Dispatcher processes are part of the
MTS (multi threaded server) architecture; they help to minimize resource needs by
handling multiple connections.
Snnn:
It is a short form used for Server Process. Server Processes are created to manage
connections to the database that require a dedicated server. Server process may perform
I/O against the data files.
1.5

EXTERNAL STRUCTURES:
The databases data files provide the physical storage for the databases data.

Thus they are both Internal structures, since they are tied directly to table spaces and
External, since they are physical files.
The following types of files although related to the database are separate from the
data files. These files include

Redo Logs

Control files

Trace files and the Alert Log

Redo logs:
Redo log files are defined in the previous section 1.4.1.

Redo logs are used to

recover the databases transactions in their proper order in the event of database cache.
The Redo log information is stored external to the databases data files.
When a transaction occurs in the database it is entered in the Redo log buffers,
while the data blocks affected by the transactions are not immediately written to disk.
This allows the database to perform batch writes to disks thus optimizing the
performance of this functions.
Each ORACLE database will have two or more online Redo log files. ORACLE
writes to online Redo log files in a cyclical fashion: after the first log file is filled, it

writes to the second log file, until that one is filled. When all the online Redo log files
have been filled, it returns to the first log file and begins overwriting its contents with
new transaction data. If the database is running in ARCHIEVE LOG mode, then the
database will make a copy of the online Redo log files before over writing them. These
Archived Redo log files can then be used to recover any part of the database to any point
in time.
Control files:
Control files record control information about all of the files within the database.
A databases overall physical architecture is maintained by its control files. They are
used to maintain internal consistency and guide recovery operations.
Since the control files are critical to the database, multiple copies are stored
online. These files are typically stored on separate disks to minimize the potential damage
due to disk failures. The database will create and maintain the control files specified at
database creation.
Trace files and Alert log:
Each of the background process running in an instance has a trace file associated
with it. The trace file will contain information about significant events encountered by the
background process.
In addition to the trace files ORACLE maintains a file called the Alert Log. The
Alert log records the commands and command results of major events in the life of the
database.
Alert log is a vital source of information for day to day management of the
database; trace files are most useful when attempting to discover the cause of a major
failure. In the simplest form an ORACLE database consists of
One or more Data files
One or more Control files
Two or more Online Redo Logs

Internally, that database contains


Multiple Users / Schemas.
One or more Rollback Segments.
One or more Table spaces.
Data Dictionary Tables.
User objects (Tables, Indexes, Views etc).
The server that access that data base consists of at a minimum
An SGA (includes the Data block buffer cache, Redo log buffer
cache and shared SQL pool)
The SMON Background process
The PMON Background process
The DBWR Background process
The LGWR Background process
User processes with associated PGAs.
This is the base configuration; everything else is optional or dependent on
ORACLE version and options you are using.
1.6 ARCHITECTURE OVERVIEW:
An ORACLE database consists of physical files, memory areas, and processes.
The distribution of these components varies depending on the database architecture
chosen.
The data in the database is stored in the physical files ( called the data files ) on
the disk. As it is used, that data is stored in memory. ORACLE uses memory areas to
improve performance and to manage the sharing of data between users. The main
memory area in a database is called the system global area (SGA). To read and write

data between the SGA and data files, ORACLE uses a set of background process that are
shared by all users.
A database server also known as an instance is a set of memory structures and
background process that accesses a set of database files. The relationship between the
servers and databases is illustrated in figure 1.5
The characteristics of the database server such as the size of the SGA and the
number of the background process -- are specified during startup. These parameters are
stored in a file called init . ora.

SERVER

SYSTEM GLOBAL AREAS

BACKGROUND PROCESSES

DATABASE

DATA BASE FILES

Figure 1.5 Server and Database in ORACLE

REFERENCES:
1. ORACLE - Oracle Press book.
2. Teach Yourself ORACLE in 21 days - SAMS Publications.

1.7

EXERCISE :-

A. SAY TRUE OR FALSE :-

1. ORACLE follow all the twelve codds rule.


2. To understand ORACLE we need to understand database and instances.
3. Table space is physical division of database.
4. ORACLE database structure can be divided into three categories.
5. Constraints to the table can be applied at any time whenever we required.
6. Roles are groups of privileges.
7. PGA facilitates the transfer of information between the users.
8. ORACLE database will have only one Redo log file.
9. There are four different types of memory structures.
10. Triggers are procedures.
B. FILL IN THE BLANKS :-

1. ORACLE is ___________ database.


2. Data in the database is stored in _________.
3. Database instance is also known as _________.
4. __________ means permission.

5. Information about statements that are run against the database resides in
__________ memory area.
6. __________ performs batch writes of changed block to the datafiles.
7. Control files record _____________ about all the files within the database.
8. ORACLE database consists of _________ Online Redo logs in the simplest
form.
9. Main memory area in ORACLE database is called as _______________.
10. Set of memory structures and background processes constitute
a _________________.

C. ANSWER THE FOLLOWING :-

1. What do you mean by an instance?


2. Explain how characteristics of tables columns can be specified.
3. Differentiate between Procedures and Functions.
4. What is Constraints? Explain the different Constraints that can be placed on
tables columns.
5. What is Rollback Segment? Explain its role.
6. Explain the need of Redo log buffer.
7. Explain the role of background process. Explain any four
major Background processes.
8. Differentiate between Trace files and Alert log.
9. Mention the different constituents of SGA.
10. Explain the importance of RECO Background process.
1.8

ANSWERS :A.

1. False

B. 1. Relational.

2. True

2. Tables.

3. False

3.

Server.

4. True

4.

Privileges.

5. False

5.

Library Cache.

6. True

6.

DBWR.

7. False

7.

Control Information.

8. False

8.

Two or more.

9. False

9.

System Global Area.

10. True

10.

==============

********

Database Server.
==================

Das könnte Ihnen auch gefallen