Oracle Database Architecture & Processes
Oracle Database Architecture & Processes
ARCHITECTURE &
PROCESSES
Introduction
Database is a collection of data treated as a
unit.
The purpose of a database is to store and
retrieve related information.
A database server is the key to solving the
problems of information management.
2
Oracle Products Family
Oracle Database 10g
Oracle Application Server 10g
HTTP Server
Forms and Reports
Discoverer Plus and Viewer (BI Products)
Portal and Wireless
Oracle Developer Suite 10g
Oracle Forms & Reports 9i
Oracle Warehouse Builder 9i (ETL Tool)
Oracle Discoverer Administrator/Desktop 9i
Oracle JDeveloper
4
Oracle Database Architecture
The database has Physical structures and
Logical structures.
The Physical and Logical structures are
separate.
The Physical storage of data can be
managed without affecting the access to
logical storage structures.
5
Oracle Database Architecture
6
Oracle Processes
7
Oracle Database Physical Structures
Datafile
Control Files
Redo Log Files
Archive File
Parameter File
Log File (alert*.log, sqlnet.log,listener.log...)
Trace File
8
Datafile
Every Oracle database has one or more
physical datafiles.
9
Datafile Characteristics
11
Redo log files &Archive Log Files
Oracle has a set of two or more redo log files. The
set of redo log files is collectively known as the
redo log for the database.
A redo log is made up of redo entries (also called
redo records).
The primary function of the redo log is to record
all changes made to data.
If a failure prevents modified data from being
permanently written to the datafiles, then the
changes can be obtained from the redo log, so
work is never lost.
12
Parameter Files
13
Alert and Trace Log Files
Each server and background process can write to an
associated trace file.
When an internal error is detected by a process, it dumps
information about the error to its trace file. Some of the
information written to a trace file is intended for the
database administrator, while other information is for
Oracle Support Services.
Trace file information is also used to tune applications and
instances.
The alert file, or alert log, is a special trace file. The alert
log of a database is a chronological log of messages and
errors.
14
Backup Files
To restore a file is to replace it with a backup file. Typically,
you restore a file when a media failure or user error has
damaged or deleted the original file.
Extents
Segments
16
Tablespaces
A database is divided into logical storage units
called tablespaces, which group related logical
structures together.
Each database is logically divided into one or more
tablespaces.
One or more datafiles are explicitly created for
each tablespace to physically store the data of all
logical structures in a tablespace.
17
Tablespaces
Relationship between
tablespaces and datafiles
Database
DATA1.ORA DATA2.ORA
DATA3.ORA
18
Tablespaces
Objects stored in tablespaces
Tablespace (one or more datafiles)
22
Extents & Segments
An extent is a specific number of contiguous data
blocks, obtained in a single allocation, used to
store a specific type of information.
Segment
Extent Extent
2K
2K
2K 2K 2K 2K
2K 2K 2K 2K
2K 2K 2K 2K
2K 2K 2K 2K
2K 2K 2K 2K
2K 2K 2K 2K
2K 2K 2K 2K
2K 2K 2K 2K
2K 2K 2K 2K
2K 2K 2K 2K
24
Database Blocks
Types of Segments
Data segment
Index segment
Temporary segment
Rollback segment
25
Data segment
Each nonclustered table has a data segment. All
table data is stored in the extents of the data
segment.
For a partitioned table, each partition has a data
segment.
Each cluster has a data segment. The data of every
table in the cluster is stored in the cluster’s data
segment.
26
Index Segment
27
Temporary Segment
Temporary segments are created by Oracle when
a SQL statement needs a temporary database area
to complete execution.
28
Rollback segment
29
Relationship – Database, Tablespace
& Datafiles
Each database is logically divided in to one or more
tablespaces.
One or more datafiles are explicitly created for each
tablespace to physically store the data of all logical
structures in a tablespace.
The combined size of the tablespace details is the
storage capacity of the tablespace.
The combined storage capacity of a database
tablespaces is the total storage capacity of the
database.
30
Overview of Schemas and Common
Schema Objects
SCHEMA
- Is a collection of Database Objects.
- Schema objects include structures like tables,
views, and indexes.
- There is no relationship between a tablespace
and a schema.
- Objects in the same schema can be in different
tablespaces, and a tablespace can hold objects
from different schemas.
31
Tables, Indexes and Views
Tables are the basic unit of data storage in an
Oracle database.
Indexes can be created to increase the
performance of data retrieval.
Views are customized presentations of data in one
or more tables or other views.
A view can also be considered a stored query.
32
Clusters & Synonyms
Clusters are groups of one or more tables
physically stored together because they share
common columns and are often used together.
A synonym is an alias for any table, view,
materialized view, sequence, procedure, function,
package, type, Java class schema object, user-
defined object type, or another synonym.
33
Data Dictionary
Data dictionary is a set of tables and views that are used as
a read-only reference about the database.
It stores information about both the logical and physical
structure of the database.
A data dictionary also stores the following information:
The valid users of an Oracle database.
34
Overview of the Oracle Instance
An Oracle database server consists of an Oracle
database and an Oracle instance.
Every time a database is started, a system global
area (SGA) is allocated and Oracle background
processes are started.
The combination of the background processes and
memory buffers is called an Oracle instance.
35
Instance Memory Structures
Oracle creates and uses memory structures to
complete several jobs.
Two basic memory structures are associated with
Oracle: the system global area and the program
global area.
System Global Area (SGA), which is shared by all
server and background processes.
Program Global Areas (PGA), which is private to
each server and background process; there is one
PGA for each process.
36
SGA (System Global Area)
A system global area (SGA) is a group of shared
memory structures that contain data and control
information for one Oracle database instance.
If multiple users are concurrently connected to the
same instance, then the data in the instance’s SGA
is shared among the users.
SGA is sometimes called the shared global area.
Oracle automatically allocates memory for an
SGA when you start an instance.
37
SGA’s Memory Structures
38
SGA Data Structures
Database Buffer Cache
- Caches the data that has been most recently
accessed by database users.
Shared Pool
- Caches the most recently used SQL statements that
have been issued by database users.
Redo Log Buffer
- Stores transaction information for recovery
purposes.
39
SGA Data Structures
Java Pool
- Caches the most recently used Java objects and
application code.
Large Pool
- Caches data for large operations such as Recovery
Manager (RMAN) backup and restore activities and
Shared Server components.
Streams Pool
- Caches the data associated with queued message
requests.
40
PROGRAM GLOBAL AREA (PGA)
PGA is a memory buffer that contains data and
control information for a server process. A server
process is a process that services a client’s
requests.
41
Oracle Background Processes
An Oracle database uses memory structures and
processes to manage and access the database.
All memory structures exist in the main memory
of the computers that constitute the database
system.
The background processes consolidate functions
that would otherwise be handled by multiple
Oracle programs running for each user process.
42
Server Processes
Oracle creates server processes to
handle requests from connected user
processes.
A server process communicates with
the user process and interacts with
Oracle to carry out requests from the
associated user process.
43
Oracle Background Processes
System Monitor (SMON) Dispatcher (Dnnn)
Process Monitor (PMON) Shared Server (Snnn)
Database Writer (DBWn) Memory Manager
Log Writer (LGWR) (MMAN)
Checkpoint (CKPT) Memory Monitor (MMON)
Archiver (ARCn) Memory Monitor Light
Recoverer (RECO) (MMNL)
Recovery Writer (RVWR)
Job Queue Monitor
(CJQn) Change Tracking Writer
Job Queue (Jnnn) (CTWR)
Queue Monitor (QMNn)
Parallel Query Slave 44
(Qnnn)
Background Processes
System Monitor (SMON)
Performs instance recovery following an instance
Database Writer
Writes modified database blocks from the SGA’s
45
Background Processes
Log Writer
Writes transaction recovery information from the
Event.
Archiver
Copies the transaction recovery information written
47
Background Processes
Queue Monitor
Monitors the messages in the message queue when
Oracle’s Advanced Queuing feature is used.
Parallel Query Slave
Used to carry out portions of a larger overall query
when Oracle’s Parallel Query feature is used.
Dispatcher
Assigns user’s database requests to a queue where
they are then serviced by Shared Server processes
when Oracle’s Shared Server feature is used.
48
Background Processes
Shared Server
Server Processes that are shared among several
users when Oracle’s Shared Server feature is used.
Memory Manager
Manages the size of each individual SGA component
when Oracle’s Automatic Shared Memory
Management feature is used.
Memory Monitor
Gathers and analyzes statistics used by the
Automatic Workload Repository feature.
49
Background Processes
Memory Monitor Light
Gathers and analyzes statistics used by the
Automatic Workload Repository feature.
Recovery Writer
Writes recovery information to disk when Oracle’s
Flashback Database Recovery feature is used.
Change Tracking Writer
Keeps track of which database blocks have changed
when Oracle’s incremental Recovery Manager
feature is used.
50
User Processes
51
Server Processes
A server process must place the data in the database buffer
cache
Parse and execute SQL statements
Read data blocks from disk into the shared database
buffers of the SGA
Return the results of SQL statements to the user process
• Parse : check syntax, security access, object resolution,
optimization
• Execute : applies the parse tree to the data, perform a physical
read and change
• Fetch : Passes data to the user (only SELECT)
52
Oracle Network
What is TNS?
Transparent Network Substrate.
Oracle’s Network applications to access the underlying
Configuration File
LISTENER.ORA ( Server )
TNSNAMES.ORA (Server ,Client )
54
How Oracle Works?
An instance has started on the computer running Oracle (often called
the host or database server).
The server detects the connection request from the application and
creates a dedicated server process on behalf of the user process.
55
How Oracle Works?
The user runs a SQL statement and commits the transaction. For
example, the user changes a name in a row of a table.
The server process receives the statement and checks the shared pool
for any shared SQL area that contains a similar SQL statement.
If a shared SQL area is found, then the server process checks the
user’s access privileges to the requested data, and the previously
existing shared SQL area is used to process the statement.
If not, then a new shared SQL area is allocated for the statement, so it
can be parsed and processed.
The server process retrieves any necessary data values from the actual
datafile (table) or those stored in the SGA.
56
How Oracle Works?
The server process modifies data in the system global area. The DBWn
process writes modified blocks permanently to disk when doing so is
efficient.