You are on page 1of 40

Database Management System Oracle

Lecture 1
Database Management System Oracle
1. Architecture of the system
2. Oracle Instance
3. Database project and creation
4. Data Dictionary
5. Management of Oracle database resources
Database Management System Oracle
Oracle Database Server 9 .2 .0 .1 .0
Major Database Release Number
Database Maintenance Release Number
Application Server Release Number
Platform Specific Release Number
Component Specific Release Number
Database Management System Oracle
Oracle Architecture
data
OS
Oracle
SQL+PL/SQL
Developer/
Designer
applications
SQL+PL/SQL
kernel
Oracle System
System
Operating
Oracle Architecture
data
Database Management System Oracle
Oracle Database Oracle Instance
Physical Structure Logical Structure
Oracle Server
Oracle Instance
Instance is a fragment of memory cut from main memory of
computer working as Oracle Server
Oracle Instance
Instance is the combination of the background processes and memory
buffers (so called System Global Area SGA)
Background Processes
are programs stored in main memory
of Oracle Server
Oracle Instance
Background Processes
Oracle Instance - visualisation
Oracle Parallel Server
Oracle Instance
1
database
=
1
instance
1
database
instance2
instance1
instancen

Oracle Instance
Background Processes
Background Processes
DBWR LGWR PMON SMON RECO ARCH CKPT DBnn SNPn
Shared
Pool
Database
Buffers
Log
Buffers
Oracle Instance
Background Processes
Shared
Pool
Database
Buffers
Log
Buffers
DBWR LGWR SMON
Redo Log Files
Datafiles
Control File
Server
Processes
User
Processes
PMON
Oracle Instance
Buffer Lists
Every buffer belongs to 2 lists: bidirectional LRU and MRU.
In case of cache hit, buffer is moved towards to LRU end.
New buffer is read in lieu of first buffer on a list and moved to end.

Oracle Instance
Storage Management
50 % - cold side 50% - hot side
LRU MRU
Data block is reading from a disk
Data were read from disk, but there
wasnt found free buffers
new data block is written into a buffer
free buffers searching direction
db_percent_hot_default
mid point
Oracle Instance
DBWR writes modified blocks from the database buffer cache to the datafiles,
when:
checkpoint occurs,
more than 3 seconds elapsed after last writing,
dirty buffers reach threshold,
there isnt any vacancies in a database buffer (there are not free buffers).
DBWR tasks
Oracle Instance
LGWR tasks
LGWR writes modified data from log buffer to redo log file, when:
checkpoint is signaled,
transaction is commited,
buffer is one-third (1/3) full,
more than 3 seconds elapsed after last writing,
DBWR wants to write its buffer onto a disk.
Oracle Instance
CKPT tasks
is responsible for signaling DBWR at checkpoints,
is responsible for updating headers of all data control files with
information about checkpoint.
Checkpoint is a system event of database, whereby data from SGA
buffers are written onto a disk SGA with database synchronization
is followed
Oracle Instance
Checkpoint
Is initialized, when:
log files groups are switched,
intervals between subsequent archive logs being written is longer than the
interval specified by LOG_CHECKPOINT_TIMEOUT parameter,
LGWR written to log file a number of blocks of log buffer (this number is
specifiied by a LOG_CHECKPOINT_INTERVAL parameter),
instance is shutdown in NORMAL or IMMEDIATE mode.
Oracle Instance
SMON tasks
performs instance recovery at instance startup,
cleans up temporary segments,
recovers dead transactions skipped during crash and instance recovery
because of file-read or offline errors,
coalesces free extents within the database to make free space contiguous
and easier to allocate.
Oracle Instance
PMON tasks
performs process recovery when a user process fails,
PMON is responsible for cleaning up the cache and freeing resources that
the process was using,
checks on dispatcher (see below) and server processes and restarts them if
they have failed,
cleans up user processes.
Oracle Instance
Background Processes
Background Processes
DBWR LGWR PMON SMON RECO ARCH CKPT DBnn SNPn
Shared
Pool
Database
Buffers
Log
Buffers
Oracle Instance
Processes
Server
Processes
User
Processes
User Processes Oracle
Processes
Server
Processes
Background
Processes
Are created in order to execute the
software code of an application program
or an Oracle tool
They perform functions on behalf of the invoking
process
Oracle Instance
Background Processes
Shared
Pool
Database
Buffers
Log
Buffers
Server
Processes
User
Processes
Multi-
threaded
Server
Process
Dedicated
Server
Process
User
Process
3
2
User
Process
1
Dispatcher
Dnnn
Oracle Instance
Background Processes
Shared
Pool
Database
Buffers
Log
Buffers
Users requests, that was accepted by dispatcher are directed to
queue-of-waiting-tasks (one database instance has one queue).
Tasks from the queue (in accordance with FIFO algorithm) are
taken and serviced by shared process services.
Then, tasks are directed to special queue-of-already-serviced-
tasks.
Every dispatcher owns private queue for such tasks.
Information from queue-of-already-serviced-tasks are forwarded
to special user process. Tasks queues are storage in SGA.
Oracle - architecture
Redo log files
The primary function is to record all changes
made to data. Should a failure prevent
modified data from being permanently written
to the datafiles, the changes can be obtained
from the redo log and work is never lost. Redo
log files are critical in protecting a database
against failures. To protect against a failure
involving the redo log itself, Oracle allows a
multiplexed redo log.
Control File
contains entries that specify the physical
structure of the database. For example, it
contains the following types of information:
database name
names and locations of a database's
datafiles and redo log files
timestamp of database creation
Physical structure of Oracle database
.log
.log
.ctrl
.dbf
CONTROL_FILES names of
control files
Oracle Instance
Background Processes
Shared
Pool
Database
Buffers
Log
Buffers
DBWR LGWR SMON
.log
.log
.dbf
.ctrl
PMON
LOG_CHECKPOINT_TIMEOUT
LOG_CHECKPOINT_INTERVAL
exists, when
CHECKPOINT_PROCESSES = true
CKPT
max time between
checkpoints
LOG_BUFFER- size of log
buffers
SHARED_POOL_SIZE
DB_BLOCK_BUFFERS - number of blocks in a buffer
DB_BLOCK_SIZE block siez
SAVEPOINTS - max. number
of transaction rollback points
ARCH SNPn
SNAPSHOT_REFRESH_PROCESSES
number of SNPn processes, that
service automatical refresh of
remote tables replication
Oracle - architecture
Initialization File
performance optimalization by memory structures customizing (for ex.
number of buffers in SGA),
setting default values for whole database during database creation,
setup limits for database (for ex. max number of database users),
naming of database files
enable:
Oracle - architecture
Sample Configuration Parameters
DB_NAME
INIT_SQL_FILES
LOG_ARCHIVE_DEST
LOG_ARCHIVE_FORMAT
USER_DUMP_DEST
BACKGROUND_DUMP_DEST
AUDIT_TRAIL
OPEN_CURSORS
PROCESSES
ROLLBACK_SEGMENTS
SQL_TRACE
TIMES_STATISTICS
Oracle Instance
Data
Dictionary
Buffer
SQL Query
stack (ariables, session tables,..),
information about user session,
private buffers of SQL commissions (variables and parameters of SQL
commissions OPEN_CURSORS)
PGA
private buffers of SQL
commands
Library Buffer
SQL commands
buffer
OPEN_CURSORS max. number of
private SQL buffers
Oracle Instance
data
dictionary
buffer
SQL query
library
buffer
data buffer
blocks from disk
are read onto the
buffers
LRU and MRU
updating


redo log
buffer
PGA
Oracle Instance
Process Memory PGA (Program Global Area) is a memory buffer that
contains data and control information for a server process. A PGA is created
by Oracle when a server process is started. The information in a PGA
depends on the configuration of Oracle. Part of PGA memory is reserved for
private buffer of SQL commands.
Oracle - architecture
Data Block
are at the finest level of granularity. One data
block corresponds to a specific number of bytes of
physical database space on disk.
A data block is the smallest unit of I/O used
by a database.
A data block size is specified for each Oracle
database when the database is created.
Logical structure of Oracle database
blocks extents segments tablespaces
extent
84 k
blocks of
database
extent
28 k
Segment
112K
Oracle - architecture
Logical structure of Oracle database
Extent
is a specific number of contiguous data
blocks, obtained in a single allocation, used
to store a specific type of information.
Segment
is a set of extents which have been allocated
for a specific type of data structure, and all
are stored in the same tablespace.
Because extents are allocated as needed, the
extents of a segment may or may not be
contiguous on disk, and may or may not span
files.
Tablespace
One or more datafiles form a logical unit of
database storage called a tablespace. A
data file can be associated with only one
tablespace, and only one database.
Oracle - architecture
Logical structure of Oracle database
its impossible to create database object that
will belonge in a several tablespaces
user cant influence data location in datafiles
table
table
index
index
Datafile no 1 Datafile no 2
Tablespace no 1
Oracle - architecture
Logical structure of Oracle Database
Tablespace no 1 Tablespace no 2
table
table
index
index
ALTER TABLESPACE tblsp1
ADD DATAFILE plik4 SIZE 2M;
table
Oracle - architecture
Why using different tablespaces?
in order to separate user data from dictionary data,
in order to separate data from different application,
in order to storage different data from tablespaces onto distinct disks,
in order to prevent total loss of data in case of disk fail,
in order to prohibit an access to data belonged to a tablespace,
in order to assign specific space quotas for database users,
to control availability of data by taking individual tablesp. online or offline,
in order to reorganize files.
Database creation
Steps of creating Database
Data are organized in tablespaces
The structure of database should prevent before fragmentation and lack of
resources
Operating System is prepared (setting of variable ORACLE_SID)
Initialization file is prepared
Instance is started
CREATE DATABASE command is executed
Security of database is provided by creating a number of log files and
control file
Tables and data dictionary views are created
Database creation
STARTUP
1. instance started
2. control file and datafiles are opened
3. log files are opened
STARTUP MOUNT
1. instance started
2. control file is opened
STARTUP NOMOUNT
1. instance started
SHUTDOWN
Steps od database start
Database creation
Modes of database shutdown
NORMAL waits for in-flight work to complete (system is waiting for
user sessions end),
TRANSACTIONAL system is waiting for user transactions end,
IMMEDIATE terminates all sessions and does a rollback on all
uncommitted transactions
ABORT aborts all sessions, leaving current DML in need of
rollback, deallocates the SGA and terminates the
background processes
Data Dictionary
Oracle Dictionary
DBA_... USER_... ALL_... V$...
groups of views

You might also like