Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 47

Oracle Database Administration

Session 2

Harvard University
The Database

A database can be viewed as the collection of


data from a business
An application presents this data to the users
in a manageable way.
The application can insert, delete or update
the data.
The database structures hold and manipulate
this data

Harvard University
The Database

The Data is stored in Relational Tables,


defined by Columns
Data is stored as Rows in the table
These tables can then be related to each
other using relationships
The database enforces these relationships

Harvard University
The Instance

A database instance (server) is a set of


memory structures and background
processes
The memory structures together makeup the
System Global Area( SGA)

Harvard University
The Instance

 This set of memory structures and background


processes are used to provide access to the data
 There can be multiple instances,or sets of memory
structures,for one database eg. Oracle Real
Application Clusters (RAC)
 A parameter file, the init.ora, is used to configure the
instance
 The parameters held in this file, determine the size
and composition of the instance

Harvard University
The Instance

This file is read during the instance startup


When changes are made to the init.ora, they
will not take effect until the next time the
database is started.
Spfile
The parameter file is used to set the name of
the instance
This is the SID (system identification) name

Harvard University
Database Structures

Three Types
– Internal to the Database
– Internal to the Memory (SGA and Processes)
– External to the Database

Harvard University
Internal Database Structures

 Tables
– Tables are the storage mechanism for data inside the
oracle database. There are made up of columns.
– Each column has a datatype and a length
 Indexes
– It is a partial copy of the data in a table
– They are used to quickly find data in the database
– An index is created when a primary key is created.

Harvard University
Views
– A method of looking at “some” of the data in a
table or in groups of tables
– Views are masks over a table or group of tables
– Views have no indexes
– There can be used to enforce security

Harvard University
Procedures
– Blocks of PL/SQL statements, called by
applications
– They do not return a value to the calling program
Functions
– Like a procedure, but can return a value to the
calling program.

Harvard University
Packages
– These hold procedures and functions in logical
groups
– A package can have PUBLIC and PRIVATE
elements
– Public, would be procedures for a USERS usage
– Private may be called by other procedures in the
package

Harvard University
Triggers
– Procedures that execute when a specific event
occurs
– Used to augment referential integrity, enforce
additional integrity
– Statement triggers
– Row triggers

Harvard University
 Sequences
– Sequential lists of unique numbers
– Used as primary Keys
 Synonyms
– Synonyms are pointers to tables, views, procedures
functions.
– To fully qualify an object we need the machine hostname,
the instance name, the objects owner and the object’s
name
– Synonyms help to simplify the interface for the user

Harvard University
Users
– Users are not physical structures in database.
– All objects are owned by a user
– All users are associated to a specific default
tablespace
– Users can be ‘granted’ access to the objects of
other users and ‘granted’ the privilege to execute
a specific function or procedure

Harvard University
Schemas
– They are related to users.
– A set of tables and other database objects are
created as a schema and are owned by a user
Database Links
– Database Links are used to reference data
outside the database
– Database links can be public or private
Rollback Segments (Undo Segments)

Harvard University
Memory Structures

– System Global Area (SGA)


Part of the System Memory
– Unix level processes

Harvard University
Harvard University
PMON SMON

Data Block
Shared Pool Redo Log Buffers
Buffers

Dictionary
Library Cache
Cache

DBW0 LGWR ARCH

3 4
2

Datafiles
Redo Log Files Archived Redo
Log Files

Harvard University
System Global Area

The Data Buffer Cache is the cache area


where data blocks are read into from the data
segments, such as tables, indexes, etc.
Its size is controlled by the db_cache_size
parameter in the init.ora file.
This space is managed by a least recently
used (LRU) algorithm

Harvard University
System Global Area

This is very important in database tuning


If data is not in this area, it must be read from
the datafile, so we have disk I/O.

Harvard University
System Global Area

The Shared Pool stores the data dictionary


cache and the library cache

Data Dictionary Cache stores data from the


data dictionary tables
These tables store information about the
database objects
It is managed by a Least Recently Used
(LRU) algorithm

Harvard University
System Global Area

The Library Cache holds information about


statements that have run against the
database
It allows the sharing of commonly used SQL
statements
It is also managed by an LRU algorithm

Harvard University
System Global Area

Their sizes are set by the shared_pool_size


parameter

Harvard University
System Global Area

The Redo log buffer holds redo data on a


transaction, before it gets written to the redo
log
Its size(in bytes) is controlled by the
log_buffer parameter

Harvard University
SGA PMON SMON

Data Block
Shared Pool Redo Log Buffers
Buffers

Dictionary
Library Cache
Cache

DBW0 LGWR ARCH

3 4
2

Datafiles
Redo Log Files Archived Redo
Log Files

Harvard University
Process Architecture
A process is a mechanism in an operating system
that can run a series of steps.
A process has its own private memory area
An Oracle database server has
– User processes
– Oracle processes

Harvard University
Background Processes

PMON cleans up failed user processes. It


wake up periodically to check if it is needed.

SMON checks to see if a database needs


recovery, on startup. It also coalesces free
space in tablespaces.

Harvard University
Background Processes

DBWR manages the data block buffer cache


and the dictionary cache. It handles the batch
writes of changed blocks from the SGA to the
datafiles. There can be multiple DBWR
processes.

Harvard University
Background Processes

LGWR manages the writing of the contents of


the redo log buffer, to the online redo log files.
It writes the log entries in batches. If the redo
logs are mirrored sets, then both are written to
simultaneously. There can be multiple LGWR
processes

Harvard University
Background Processes

ARCH performs the archiving of the redo log


files. LGWR writes to the redo log files in a
round robin fashion. When all are full, it over-
writes the first one. However, if the database
is in archive mode, Oracle takes a copy of this
file and stores it on disk.

Harvard University
Oracle Instance
Memory structures

PMON SMON DBW0 LGWR

Database
Datafiles, Control files, etc

Harvard University
The Physical World

The computer system


– The operating system
– Memory Modules
– Storage Disks
– Processors
– Daemons
printers
Networks
– Files

Harvard University
System

Information on a computer is stored in bytes


Bytes are grouped into Blocks
The Operating System usually has 512 bytes
in a block
1K = 1024 bytes
Oracle data is also stored in bytes
Oracle data blocks are in 2k,4k,8k,16, or 32k
bytes
Harvard University
System

Oracle data blocks are multiples of the


Operating System blocks
The computer memory uses the same block
sizes as the disk storage

Harvard University
System

The O/S software is Solaris 2.8 or 2.9


It is the layer between the computer hardware
and the Oracle Software
It manages the computer system
– writes to disk
– reads from disk
– controls printing
– controls network connections

Harvard University
The OFA Standard

/u 0 1 /u 0 2 /u 0 3 /u 0 4 /u 0 5

/a p p /a p p / o r a d a ta / o r a d a ta

/ o r a c le /(o th e r a p p lic a tio n s ) /($ S ID ) /($ S ID )


( $ O r a c le _ b a s e )

Harvard University
Oracle Directory Structure

/u 0 1 /a p p /o r a c le ($ O R A C L E _ B A S E )

a d m in p ro d u c t

< S ID _ N A M E > $O RACLE_HO M E

bdum p udum p p f i le cdum p a rch c r e a te n e tw o rk dbs b in

Harvard University
Files

Datafiles contain the actual data stored in a


database
The Parameter file contain the initialization
parameters used to create the memory area it
will use, to manage the database
Control files map the physical files of the
database to the logical tablespaces and online
redo logs. It helps ensure the database
remains consistent

Harvard University
Files

 Redo files contain enough information to allow Oracle


to reconstruct or back out a transaction, if the
database should shutdown before these changes
have been written to the disk
 INSERT, UPDATE, DELETE, CREATE, ALTER, or
DROP operations generate redo
 Alert and Trace files contain information on the health
of the database and provides warnings when
problems occur

Harvard University
Files

Backup files contain copies of the database


files and can be used to recover the database.
The standard convention for file extensions or
endings to file names are
– data files .dbf
– control files .ctl
– redo log files .dbf (some use .rdo)
– parameter file .ora

Harvard University
Datafiles and Tablespaces

Harvard University
Oracle’s “Logical” World

A Tablespace is a logical division of a


database.
Each tablespace is made up of one or more
datafiles.
 A datafile belongs to one tablespace

Harvard University
A tablespace can belong to only one
database

There must be at least one tablespace called


SYSTEM, to create a database

Other include USERS, UNDO, TOOLS, etc.

Harvard University
Undo segments

Undo segments hold the before image of the


data in a transaction
As a program begins to change the data in
the database, Oracle changes the physical
blocks that contain that information.
Before changing the data block buffers in the
SGA or writing to disk, Oracle takes a copy of
this data in an undo segment

Harvard University
Tablespace Examples
– System holds all objects owned by the sys
user
– SYSAUX is an auxiliary tablespace to the
SYSTEM tablespace
– Rollback (RBS) (undo) is used to store the
rollback segments
– Temp (Temporary) is used for sort functions.

Harvard University
Tablespace Examples

– Users is the default space for user accounts


– Tools should be the default space for the system
user, after database creation.
– Data holds the ‘real’ application data
– Index holds the index data for the application

Harvard University
Reading

10g Concepts Guide


– Part 2
Chapter 3 Tablespaces,datafiles and control files
Chapter 5 Schema Objects
Chapter 7 The Data Dictionary
The two installation guides
– A quick review of each. Look them over to
identify an overall process

Harvard University

You might also like