505 - Unit 1 - RDBMS
505 - Unit 1 - RDBMS
1. Oracle Instance
The combination of set of memory structure and operating system background processes is
known as oracle instance. Every oracle database has one instance associated with it. Every
oracle database is mounted with one oracle instance except with oracle parallel server.
Whenever database is started, a system global area (SGA) is allocated and Oracle
background processes are started. Each background processes are allocated a separate
memory block which is used for different purposes like to store private variables, address
stack and other run time information.
The memory block which is used as shared memory area and a part of memory that can be
written to and read from at same time by many programs is known as System Global area
(SGA).
Oracle instance combines both background processes as well as system global area
(shared memory region).Background processes of oracle are compared with hands which
handles all the components of oracle instance directly.SGA is a brain which indirectly
support the background processes.
Oracle instance is created during the nomount stage of database, after database is passes
though this stage parameter file init.ora is read and also background processes are also
started and system global area is initialized. The init.ora file defines many information like
size of memory structure, number of processes, types of processes about configuration of
oracle instance.
The next stage is opening the database, in this stage database whose names are stored
within control file are locked for only exclusive use by instance and database is also
accessible to normal user.
2. Memory Architecture
An Oracle server creates and uses memory structures and processes to manage and
access the database. Oracle server uses memory structure to store many information such
as code of program that is executed and the data that is shared among the users, Details
about a connected session, even if it is not currently active, Information that is shared and
communicated among Oracle processes, Cached data that is also permanently stored on
memory (for example, data blocks and redo log entries).
The SGA is the Primary component of the oracle instance. A group of shared memory
structures that contain data and control information for one Oracle database instance is
known as System Global Area (SGA).SGA contains all the memory structures necessary for
data manipulation, SQL statement parsing and redo caching.SGA is also known as shared
global area because multiple user can access and modify data in the instance's SGA at the
same time.
A SGA and Oracle processes combines an Oracle instance. Oracle automatically allocates
memory for an SGA when an instance is created , and the operating system reclaims the
memory when you shut down the instance. Each instance has its own SGA.
The SGA is read/write. All users connected to a multiple-process database instance can
read information contained within the instance's SGA, and several processes write to the
SGA during execution of Oracle.
The buffers in the cache are organized in two lists: the write list and the least recently used
(LRU) list. The write list holds dirty buffers, which contain data that are modified is known as
dirty buffers but has not yet been written to disk.These blocks are placed on the dirty list.The
dirty list keeps track of all modification made to cache that have not moved to disk.
The Oracle fetch data out of the buffer cache according to a recently used list(LRU).LRU
keeps track of what data blocks are accessed and how often.When an Oracle process
accesses a buffer, the process moves the buffer to the most recently used (MRU) end of the
LRU list.
SSCCS BCA RDBMS UNIT - 1 DBMS AND RDBMS CONCEPTS & INTRODUCTION TO ORACLE SERVER ARPIT PAREKH
The redo log buffer is used to store information about changes made to the database before
it is flushed to online redo log files.This information is stored in redo entries. Redo entries
contain the information necessary to reconstruct, or redo, changes made to the database by
INSERT, UPDATE, DELETE, CREATE, ALTER, or DROP operations. Redo entries are
used for database recovery, if necessary.
The redo entries are allocated continuous, sequential space in the buffer. The background
process LGWR writes the redo log buffer to the active redo log file (or group of files) on disk.
Redo log Buffer is a circular buffer which means it fills from top to bottom and again return to
beginning of the buffer.whenever redo log buffer fills, its content are written to online redo log
files.
Log Writer
Process
Shared pool
The shared pool of the SGA contains the library cache, the dictionary cache and control
structures.
library cache stores text,execution plan of SQL statement that have submitted to RDBMS,as
well as the headers of PL/SQL packages and procedures that have been executed.Library
cache is used to improve the performance of Sql Statements. The library cache also
includes the shared SQL areas and private SQL areas.Shared SQL area contains parse
SSCCS BCA RDBMS UNIT - 1 DBMS AND RDBMS CONCEPTS & INTRODUCTION TO ORACLE SERVER ARPIT PAREKH
tree and execution path for SQL statements.private SQL area contains information such as
bind variables,environment variable,runtime stack and buffer.A Private Area is allocated for
each transaction made and deallocated after cursor is closed.
The data dictionary is a collection of database tables and views contains information about
the database, its structures, and its users.
Large Pool:
Large pool is an optional memory area that provides large allocation of memory block to
many operations such as Oracle backup and restore operations,I/O Server Processes,
Session memory for the shared server and the Oracle XA interface( used where transactions
interact with more than one database).
In buffers of a few hundred kilobytes are allocated for Oracle backup and restore operations,
for I/O server processes, and for parallel buffers.for that Large pool is better option to satisfy
large memory requests than the shared pool.
Java Pool:
Java pool memory is used within server memory for all session-specific Java code and data
within the JVM. Java pool memory is used in different ways, depending on what mode the
Oracle server is running in.
Streams Pool:
Stream Memory can be allocated from pool in the SGA is known as Stream pool in single
database.for configuration the stream pool ,the size of the pool in bytes are specify using
STREAMS_POOL_SIZE initialization parameter.if it is not defined ,then one is created
automatically when streams is first used.
A program global area (PGA) is a memory region that contains data and control information
for a server process. PGA is a nonshared memory created by Oracle when a server process
is started. PGA is access only by server processes and read and written only by oracle code
which acts on behalf of it
The allocation and deallocation of private SQL areas depends on application tool that you
are using, although the number of private SQL areas that a user process can allocate is
always limited by the initialization parameter OPEN_CURSORS. The default value of this
parameter is 50.
SSCCS BCA RDBMS UNIT - 1 DBMS AND RDBMS CONCEPTS & INTRODUCTION TO ORACLE SERVER ARPIT PAREKH
3. Oracle Process Architecture
A process is a one type of thread control or a mechanism of an operating system that can
execute a series of steps. Sometimes it is known as job or task. A process normally has its
own private memory area in which it runs.
The purpose of database is to manage data needed by multiple users at the same time, for
this reason most database system are multiuser.It uses several oracle processes to run
different parts of the oracle code.
Each process in an Oracle instance performs a specific job. By dividing the work of Oracle
and database applications into several processes, multiple users and applications can
connect to a single database instance simultaneously while the system maintains excellent
performance.
The processes in an Oracle system can be categorized into following major groups:
User processes:
Oracla creates a user process to run the user’s application program such as pro*C Program
or oracle tool such as SQL*Plus. User processes also manage communication with the
server process through the program interface.
Connection and session are closely related to user process but are very different in
meaning.
Server Process:
Oracle creates server processes to handle the requests of user processes connected to the
instance. A server process establish communicates with the user process and interacts with
Oracle to carry out requests from the associated user process. For example, if a user
queries some data which is not available in database buffers of the SGA, then the
associated server process reads the proper data blocks from the datafiles into the SGA.
Server processes created on behalf of each user's application can perform one or more
tasks such as Parse and run SQL statements issued through the application,Read
necessary data blocks from datafiles on disk into the shared database buffers of the SGA, if
the blocks are not already present in the SGA,Return results in such a way that the
application can process the information.
Background Process:
Log The log writer process (LGWR) is responsible for writing the redo log
Writer(LGWR) buffer in SGA to the online redo log file on disk. LGWR writes one
contiguous portion of the buffer to disk.LGWR writes during several
internal events such as commit, checkpoint and log write timeout, the
redo log buffer becomes one-third full or DBWR completes a flush of the
data buffer blocks at checkpoint. The Redo Log files are used to recover
the database in case of database failure.
PMON(Process PMON is responsible for recovery of user processes. it also cleans the
Monitor) database buffer cache and freeing resources that the user process was
using. It checks the status of dispatcher and server processes, and
restarts any that have stopped running.
SMON(System SMON is responsible for recovery during start up. It is also responsible
Monitor) for cleaning up temporary segments that are not longer used and for
coalescing contiguous free extents within dictionary managed
tablespaces.SMON recovers any terminated transactions which were
skipped during instance recovery due file-read or offline errors.Other
background processes can call SMON if they detect a need for it.
ARCH(Archiver) The Archiver (ARC) copies online redo log files, once they become full,
to a specified storage device or location. It is present only when the
database is started in ARCHIVELOG mode.
Table
View
Sequence
Index
Synonymos
Cluster
Table:
Table are basic unit of data storage in oracle database.In table data are store in rows and
columns.Table can be define with a table name and set of columns for example employee is
a table and set of columns such as employee_id,employee_name and job_id.In table each
column is given a column name,datatype and size.
The size for date datatype is predetermine,if datatype is number ,user can define precision
and scale instead of size. A row is a collection of column information corresponding to a
single record.
Rules can be apply for each column of a table. These rules are called integrity constraints.
One example is a UNIQUE integrity constraint. This constraint forces the column to contain a
unique value in every row.
After you create a table, insert rows of data using SQL statements. Table data can then be
queried, deleted, or updated using SQL statement.
View:
A view is a presentation of the data contained in one or more tables or other views.A view
takes the output of a query and treats it as a table. Therefore, a view can be thought of as a
stored query or a virtual table. You can use views in most places where a table can be used.
SSCCS BCA RDBMS UNIT - 1 DBMS AND RDBMS CONCEPTS & INTRODUCTION TO ORACLE SERVER ARPIT PAREKH
A view is not allocated any storage space and does not contain any data. but, a view is
defined by a query that extracts or derives data from the tables that the view references.
These tables are called base tables. Base tables can be actual tables or can be views
themselves. Because a view is based on other objects, a view requires no storage other
than storage for the definition of the view i.e stored query in the data dictionary.
For example, the employees table has several columns and numerous rows of information. If
you want users to see only five of these columns or only specific rows, then you can create a
view of that table for other users to access.
View and table have many similarities.just like a table, You can query views, and with some
restrictions you can update, insert into, and delete from views. All operations performed on a
view actually affect data in some base table of the view and are subject to the integrity
constraints and triggers of the base tables.
Sequence:
For example, assume two users are simultaneously inserting new employee rows into the
employees table. By using a sequence to generate unique employee numbers for the
employee_id column, neither user has to wait for the other to enter the next available
employee number. The sequence automatically generates the correct values for each user.
SQL statements can be used to reference the sequence. You can issue a statement to
generate a new sequence number or use the current sequence number. After a statement in
a user's session generates a sequence number, the particular sequence number is available
only to that session. Each user that references a sequence has access to the current
sequence number.
Index:
Indexes are optional structures associated with tables and clusters. Indexes can be created
to increase the performance of data retrieval. Just as the index in this manual helps you
quickly locate specific information, an Oracle index provides an access path to table data.
Indexes are created on one or more columns of a table to speed SQL statement execution
on that table. After it is created, an index is automatically maintained and used by Oracle.
Changes to table data such as adding new rows, updating rows, or deleting rows are
automatically incorporated into all relevant indexes with complete transparency to the users.
Indexes are the primary means of reducing disk I/O when properly used. When processing a
request of client, Oracle can use some or all of the available indexes to locate the requested
rows efficiently. Indexes are useful when applications frequently query a table for a range of
rows.
SSCCS BCA RDBMS UNIT - 1 DBMS AND RDBMS CONCEPTS & INTRODUCTION TO ORACLE SERVER ARPIT PAREKH
Synonymous:
A synonym is an alias for any table, view, materialized view, sequence, procedure, function,
package, type, user-defined object type, or another synonym. synonym is simply an alias, it
requires no storage other than its definition in the data dictionary.
Synonyms are often used for security and convenience. Synonyms can do the following:
o Mask the name and owner of an object
o Provide location transparency for remote objects like vie,index of a distributed
database
o Provide public access to user
o Simplify SQL statements for database users
o Enable restricted access similar to specialized views when exercising fine-grained
access control
Synonums can be created either public or private. A public synonym is owned by the special
user group named PUBLIC and every user in a database can access it. A private synonym is
in the schema of a specific user who has control over its availability to others.
Cluster:
Clusters are an optional method of storing table data. A cluster is a group of tables that
share the same data blocks because they share common columns and are often used
together. For example, the employees and departments table share the department_id
column. When you cluster the employees and departments tables, Oracle physically stores
all rows for each department from both the employees and departments tables in the same
data blocks.
Clusters store related rows of different tables together in the same data blocks,Disk I/O is
reduced for joins of clustered tables and it also improves Access time for joining of clustered
tables.
An Oracle database has both a physical and a logical structure. Because the physical and
logical server structures are separate, the physical storage of data can be managed without
affecting the access to logical storage structures.
Physical structure of an oracle database is determined by the operating system files that
contain database. The physical database structures of an Oracle database, including
datafiles, redo log files, and control files.
Datafiles:
One or more physical data file are assigned to each oracle database And these files contain
all the database data. The data of logical database storage unit such as tables and indexes
is physically stored in the datafiles allocated for a database.
A data file can be associated with only one database. Database files are automatically
updatable when the database runs out of space.
SSCCS BCA RDBMS UNIT - 1 DBMS AND RDBMS CONCEPTS & INTRODUCTION TO ORACLE SERVER ARPIT PAREKH
The data in a datafile can be read, as needed, during normal database operation and stored
in the memory cache of Oracle. For example, assume that a user wants to access some
data in a table of a database. If the requested information is not already in the memory
cache for the database, it is read from the appropriate datafiles and stored in memory.
Every Oracle database has a set of two or more redo log files. The set of redo log files is
known as the redo log for the database. A redo log is made up of redo entries.
The basic function of the redo log is to record all changes made to data. Redo log files are
critical in protecting a database against failures, whenever 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.
The information contain in a redo log file is used only to recover the database from a system
or media failure that prevents database data from being written to a database's datafiles.
For example, if an unexpected power outage abruptly terminates database operation, data in
memory cannot be written to the datafiles and the data is lost. However, any lost data can be
recovered when the database is opened, after power is restored. By applying the information
in the most recent redo log files to the database's datafiles, Oracle restores the database to
the time at which the power failure occurred.
The process of applying the redo log during a recovery operation is called rolling forward.
Control files:
Every oracle database has control files. It contains details that specify the physical structure
of database such as Database name, Names and locations of datafiles and redo log files,
Time stamp of database creation.
Oracle can multiplex the control file, that is, maintain a number of identical control file copies,
to protect against a failure involving the control file.
Every time an instance of an Oracle database is started, its control file is used to identify the
database and redo log files that must be opened for database operation to proceed.
The database's control file is automatically modified by Oracle to reflect the change
whenever the physical makeup of the database is altered (for example, a new datafile or
redo log file is created). A database's control file is also used if database recovery is
necessary
Tablespace:
Every oracle database is divided into logical storage units known as tablespace. Tablespace
group related logical structure together. For example, tablespaces commonly group together
all application objects to simplify some administrative operations.
Each database is logically divided into one or more tablespaces.To physically store the data
of all logiacl structure in a tablespace one or more datafiles are explicitly created for each
SSCCS BCA RDBMS UNIT - 1 DBMS AND RDBMS CONCEPTS & INTRODUCTION TO ORACLE SERVER ARPIT PAREKH
table space.The combined size of the datafiles in a tablespace is the total storage capacity
of the tablespace.
Every Oracle database contains a SYSTEM tablespace and a SYSAUX tablespace which
are creataed by oracle automaticaly when the database is created.
A tablespace can be eihter online or offline .A tablespace is online means accessible to user
or user can access the information within the tablespace. A tablespace is offline means
unavailable to user or to make a portion of the database unavailable while allowing normal
access to the remainder of the database.
Oracle allows fine-grained control of disk space usage through the logical storage structures,
including data blocks, extents, and segments.
Data Blocks:
At the first level of storage, Oracle database data is stored in data blocks. One data block is
assign specific number of bytes of physical database space on disk. The standard block
size is specified by the DB_BLOCK_SIZE initialization parameter. In addition, you can
specify up to five other block sizes. A database uses and allocates free database space in
Oracle data blocks.
Extent:
After Data block The next level of logical database space is an extent. Number of coniguous
data blocks forms an extent which is obtained in a single allocation, used to store a specific
type of information.
Segment:
The next level of logical database storage above an extent is called a segment. A segment is
a set of extents allocated for a certain logical structure. For example, the different types of
segments include the following:
Data Segment:
All the table's data is stored in the extents of its data segment. Each cluster has a data
segment. The data of every table in the cluster is stored in the cluster's data segment. Each
non-clustered table has a data segment.
Index Segment:
Each index has an index segment that stores all of its data.
Rollback Segment:
Database administrator can create one or more rollback segments to store temporarily
“undo” information. This information is used during database recovery and to rollback
uncommitted transactions for users.
SSCCS BCA RDBMS UNIT - 1 DBMS AND RDBMS CONCEPTS & INTRODUCTION TO ORACLE SERVER ARPIT PAREKH
Temporary Segment:
Oracle creates temporary segment when a SQL statement needs a temporary work area to
complete execution. When the statement finishes execution, the temporary segment's
extents are returned to the system for future use.