PIA Training Centre Prime Communications
PIA Training Centre Prime Communications
PIA Training Centre Prime Communications
NOTES:
A user process is spawned on a client machine in a client server configuration, when a tool such as
SQLPlus or a user developed application is started on a client. User process includes the User Program
Interface(UPI).
A server process is spawned that communicates with the Oracle Server on the host machine when a tool or
application runs on the same machine as the Oracle server(host based connection). The server process uses
an area of shared memory described as the Program Global Area(PGA). Server process uses the Oracle
Program Interface(OPI) to communicate with the Oracle server.
An Oracle server contains and Oracle instance and an Oracle database. The Oracle instance is a set of
memory structures and a group of background processes. The Oracle database is a set of files.
ORACLE_SID is an O/S environment variable that is set to define the Oracle instance name. An Oracle
instance can only reference one Oracle database at a time.
SGA: (System Global Area, sometimes call the Shared Global Area) is a group of shared memory
structures. The SGA is made up of the following structures:
1) The Shared Pool - Comprised of the Library Cache (also know as the Shared SQL Area) and the Row Cache
(also know as the Dictionary Cache or Data Dictionary Cache). Sized specified by SHARED_POOL_SIZE
variable in the parameter file.
Library Cache - Contains the following for the most recently used SQL statement: Statement
text, parsed code (parse tree), and execution plan.
Row Cache(also known as the data dictionary cache or dictionary cache) - Contains most recently
used Oracle data dictionary tables definitions and the system catalog and privileges of all users. Accessed
during the parse phase to resolve object names used in SQL statements and validate access privileges.
2) Database Buffer Cache - Contains x amount of database buffers as specified by the DB_BLOCK_BUFFERS
initialization parameter in the size of DB_BLOCK_SIZE. Also contains the dirty buffer write queue, which
holds dirty block buffers (i.e. already written to) until they can be written to disk. Least recently used(LRU)
algorithm used to decide which buffers to move out of the buffer cache to make room for new buffers to be read in.
3) Redo Log Buffer - The size of the redo log buffer is specified by the LOG_BUFFER initialization parameter.
Circular buffer containing information about changes made to the database. Records are written from the redo log
buffer to the online redo log files by the LGWR process.
!!Note!!: User session info is stored in Shared Pool when Oracle running in MTS (Multithreaded
Server) mode. Otherwise user info stored in the PGA.
PGA (Program Global Area) - Used by a single server or background process. Is allocated and
deallocated when a user process is started and terminated. In a dedicated server configuration the PGA
has and does the following:
Page 1
PIA Training Centre Prime Communications
There are four mandatory processes. If any of these processes fail the instance will crash and have to be
restarted!
PMON (Process Monitor)
Cleans up abnormally terminated user sessions
Rolls back any uncommitted transactions
Releases locks held by a terminated process
Frees SGA resources allocated to the failed process
Restarts failed shared server and dispatcher processes
Identified deadlocks
SMON (System Monitor)
Performs automatic instance recovery
Reclaims space used by temporary segments no longer in use
Merges contiguous areas of free space in the datafiles. Known as defragging or coalescing.
DBWR (Database Writer)
Writes all changed (i.e. dirty) buffers to datafiles.
Uses a LRU (least recently used) algorithm to keep most recently used blocks in memory.
Defers writes for I/O optimization.
Will write dirty blocks when one of the following occurs:
1. The dirty list reaches a threshold value
2. A process scans a specified number of buffers in the LRU list without finding a free buffer
3. A time-out occurs
4. A checkpoint occurs
LGWR (Log Writer) - Writes information from the redo log buffer to the redo log files.
There is only one redo log writer per instance.
A commit confirmation is not issued until the transaction has been recorded in the redo log file.
Commits performed by other users before LGWR flushes the buffer on behalf of a user's commit
are piggybacked to achieve an average of less than one I/O per commit.
During very long transactions, the redo log buffer pool can become more than one-third full
before LGWR writes it to the redo log file.
Will write redo log buffer entries to the redo log files when:
1. A commit occurs.
2. The redo log buffer pool becomes one-third full.
3. The DBWR completes cleaning the buffer blocks as during a checkpoint.
4. A LGWR time-out occurs(every 3 seconds).
Page 2
PIA Training Centre Prime Communications
Page 3
PIA Training Centre Prime Communications
Logs the values of all non-default initialization parameters at the time of database and instance
startup.
Located in destination specified by BACKGROUND_DUMP_DEST.
Should be checked at least daily.
Trace Files:
Contains internal errors detected by server or background processes.
If dumped by a background process the file is located in destination specified by initialization
parameter BACKGROUND_DUMP_DEST.
If dumped by server process the file located in destination specified by initialization parameter
USER_DUMP_DEST.
Are created if SQL_TRACE parameter is TRUE.
Are created if SQL_TRACE is enabled for a session.
This step is only performed for SELECTs. Not for INSERT, UPDATE, or DELETEs.
5) FETCH
For SELECT only. Returns dataset into BIND variables.
Criteria for reuse of execution plan:
1. Current SQL statement must be identical to statement already parsed, including upper/lower case,
white space, and commas.
2. Referenced objects are identical.
3. The types and names of variables are identical.
4. The parsed execution plan must be in the shared pool at the same time the current sql statement
trying to reuse it is looking for it.
Page 4
PIA Training Centre Prime Communications
If no index exists, full table scan is performed. Every block of a table is read into buffer cache
until required row is found.
Blocks read into db buffer cache using an index stay in cache longer than those from a full table
scan. This is called the modified LRU (least recently used) algorithm.
Some server manager commands that do not require a connection to the database are: EXIT REMARK SET SHOW
SPOOL. Know all the SHOW commands and what they display.
Oracle Enterprise Manager - GUI used to tune, monitor and administer databases. Contains various components
such as the OEM Console which contains a menu, launch palette, navigator, map, job system, and event system. The
OEM Repository is a special set of tables used by OEM within a database for each administrator. Standard OEM
applications include the Instance Manager, Schema Manager, Security Manager, Storage Manager, SQL Worksheet,
Backup Manager, and Data Manager. Be sure you know what each of these modules does! A Performance Pack can
also be purchased with OEM. The Performance Pack contains the following additional modules: Top Session
Monitor, Lock Manager, Advanced Events, Tablespace Manager, Trace, and Expert.
SQLLoader - Oracle's tool for loading data from "flat" text files into the Oracle database.
Import/Export Utility - Oracles tool for exporting and importing data to and from Oracle-formatted files.
Password Utility File - Used to password file for a database.
Page 5
PIA Training Centre Prime Communications
O/S Authentication
On UNIX user must be a member of the UNIX dba group.
Use when a secure connection is not possible.
Set REMOTE_LOGIN_PASSWORDFILE parameter to NONE. This is the default for this parameter.
CONNECT / AS (SYSDBA or SYSOPER)
**See Oracle notes for NT "group" and "userid" set up requirements to use O/S authentication. Oracle8 no
longer support setting the DBA_AUTHORIZATION=BYPASS parameter in the registry to allow
connections without using a password.
Password Authentication
Create the password file using ORAPWD on UNIX or ORAPWD80 on NT.
Set REMOTE_LOGIN_PASSWORDFILE parameter to EXCLUSIVE (only one instance can use the
password file and the file contains other userids besides SYS and SYSTEM) or SHARED (more than one
instance can use the password file. SYS and INTERNAL are the only users known to the password file)..
Parameter File
Referred to as the init<SID>.ora file. If sid=orcl then file name = initorcl.ora . The file is read at time of
system startup. Changes to the parameter file will take effect only after the database has been stopped and
restarted.
Default Location in UNIX = /$ORACLE_HOME/dbs. Default location in NT = %ORACLE_HOME
%\database.
OEM needs to have a local copy of the parameters file to start a remote instance or db. However, OEM can
also store multiple database startup configurations in it's registry and this removes the need to have versions
of multiple parameter files stored on the machine acting as the OEM console.
For the test, be sure and know the uses and rules for setting the various parameters that live in the
init<sid>.ora file. You should know and be very familiar with the following parameters:
BACKGROUND_DUMP_DEST , COMPATIBLE , CONTROL_FILES , DB_BLOCK_BUFFERS ,
DB_NAME , SHARED_POOL_SIZE , USER_DUMP_DEST , IFILE , LOG_BUFFER ,
MAX_DUMP_FILE_SIZE , PROCESSES , SQL_TRACE , TIMED_STATISTICS .
Page 6
PIA Training Centre Prime Communications
Instance Recovery
SMON will automatically perform instance recovery when opening up the database if database crashed or
was shut down using abort.
1. Rolls forward txns recorded in online redo log that have not been recorded in the data files.
2. Opens database before all roll forward txns have been applied.
3. SMON rolls back any uncommitted txns.
Database Shutdown Stages:
CLOSE - Write buffer cache and redo buffer changes, close online redo log and data files. Control
file remains open.
DISMOUNT - Control files are closed.
SHUTDOWN - Trace and Alert files closed, SGA deallocated, background processes are stopped.
Additional Database Startup "Modes"
Should always issue SHUTDOWN NORMAL and STARTUP NORMAL afterwards.
Page 7
PIA Training Centre Prime Communications
MAX_DUMP_FILE_SIZE limits the size of the user requested traces files. This value is specified in O/S
blocks.
Page 8
PIA Training Centre Prime Communications
The DICTIONARY and DICT_COLUMNS views contain information about the data dictionary views and
what columns they contain.
Sequential writes to the current online redo log by the LGWR process occur when either of the following
happen:
1. A commit occurs
2. redo log buffer poll gets one-third full
Page 9
PIA Training Centre Prime Communications
Page 10
PIA Training Centre Prime Communications
Minimum size of an online redo log is 50K. Final size might depend upon the frequency of log switches
and checkpoints, amount of redo generated by application and amount of available storage.
When all members of of the current or next group become inaccessible, the instance will shutdown.
Related info:
Checkpoints should occur more frequently than log switches.
If redo logs are big, increase checkpoints
'ALTER SYSTEM SWITCH LOGFILE' forces a checkpoint.
'ALTER SYSTEM CHECKPOINT' performs a fast checkpoint.
Some defaults:
Min size of INITIAL is 2*db_block_size. Default size of INITIAL = 5 db blocks.
Min size of NEXT is one block. Default is 5 db blocks.
The min and default for MINEXTENTS = 1.
Min value of PCTINCREASE = 0 and the default is 50.
Min value of MAXEXTENTS=1 default is a function of the db block size.
Know how to make a tablespace temporary.
Know how to add a data file to a tablespace.
Know how to use the autoextend feature.
Know how to change the size of a data file manually.
Know how to change t he storage settings of a tablespace. ALTER TABLESPACE MINIMUM EXTENT to
change the minimum extent allocated.
Know how to take a tablespace offline.
Some ALTER TABLESPACE offline options:
Page 11
PIA Training Centre Prime Communications
Types of segments:
1. Table Segment - Unclustered or nonpartitioned tables.
2. Table Partition - Data within a table can be stored in multiple partitions and each partition can
exist in a different tablespace if desired. Each partition can have it's own storage parameters. Helps to
reduce I/O contention by distributing the table data. Requires the use of the Oracle8 Partition option.
3. Cluster - Rows are "clustered" together based upon key column value(s). A cluster can contain
multiple tables. Is a type of data segment. Objects in a cluster belong to the same segment and share the
same storage values.
4. Index Organized Table - Data is actually stored in the index. All data retrieved from index tree,
no table lookup needed.
5. Index Partition - Contain index partitions. An single index partition can NOT span multiple
tablespaces. Helps to reduce I/O contention by distributing the index data. Requires the use of the Oracle8
Partition option.
6. Rollback Segment - Holds rollback data for undo changes, read-consistency and recovery.
7. Temporary Segment - Contain intermediate results data such as that used for sort operations.
8. LOB Segment - Large Objects such as pictures, documents or video clips. If the actual value
placed in this column is large oracle actually stores the data in separate LOB segments and the table
segment will only contain a locator or pointer to the LOB segment.
9. LOB Index - Is automatically created when an LOB segment is created. Used to lookup LOB
segment values.
10. Nested Table - A table that is actually stored in a column of a table. Also referred to as an inner
table. Stored in it's own segment separate from the "parent" table. requires the Oracle8 Objects option.
SYSTEM tablespace.
If a user is going to create tables in other tablespaces besides SYSTEM at least one more rollback
segment is required.
All rollback segments should be the same size. The PCTINCREASE storage parameter value is
not allowed. Is always equal to zero (0) for rb segs.
Page 12
PIA Training Centre Prime Communications
Page 13
PIA Training Centre Prime Communications
Page 14