34
Introduction to Oracle 10g Database Eryk Budi Pratama

Oracle 10g Introduction 1

Embed Size (px)

DESCRIPTION

Introduction to Oracle 10g for Advanced Database lab at Informatics Engineering Bakrie University.

Citation preview

Page 1: Oracle 10g Introduction 1

Introduction to Oracle 10g DatabaseEryk Budi Pratama

Page 2: Oracle 10g Introduction 1

Agenda• Review SQL Statements• Oracle Architecture (Physical Structure)• Oracle Architecture (Logical Structure)• Oracle Instance• User Process• Program Global Area (PGA)• System Global Area (SGA)• Oracle Background Process

Page 3: Oracle 10g Introduction 1

Review

• Data Definition Language• Data Manipulation Language• Data Control Language

Page 4: Oracle 10g Introduction 1
Page 5: Oracle 10g Introduction 1

PL/SQL

• PL/SQL is a powerful extension to SQL that not only adds condition testing, looping, and exception handling, but also allows developers to write application-specific functions, procedures, packages, and triggers

Page 6: Oracle 10g Introduction 1
Page 7: Oracle 10g Introduction 1
Page 8: Oracle 10g Introduction 1
Page 9: Oracle 10g Introduction 1
Page 10: Oracle 10g Introduction 1

Oracle Server Architecture

Page 11: Oracle 10g Introduction 1

Oracle 10g Physical Structure

Page 12: Oracle 10g Introduction 1

Physical Structures• Datafiles (*.dbf)The datafiles contain all the database data. The data of

logical database structures, such as tables and indexes, is physically stored in the datafiles allocated for a database

• Control Files (*.ctl)A control file contains entries that specify the physical

structure of the database such as Database name and the Names and locations of datafiles and redo log files

• Redo Log Files (*.log)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

Page 13: Oracle 10g Introduction 1

Physical Structures (cont.)• Archive Log Files (*.log)• Oracle automatically archives log files when the database is in

ARCHIVELOG mode. This prevents oracle from overwriting the redo log files before they have been safely archived to another location.

• Parameter Files (initSID.ora)• Parameter files contain a list of configuration parameters for

that instance and database.

• Alert and Trace Log Files (*.trc)• 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.

Page 14: Oracle 10g Introduction 1
Page 15: Oracle 10g Introduction 1

Oracle 10g Logical Structure

Page 16: Oracle 10g Introduction 1

Logical Structures• TablespaceA database is divided into logical storage units called

tablespaces, which group related logical structures together. One or more datafiles are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace.

• Data BlocksAt the finest level of granularity, Oracle database data is stored

in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk.

Page 17: Oracle 10g Introduction 1

Logical Structures (Cont)• ExtentsAn extent is a specific number of contiguous data blocks,

obtained in a single allocation, used to store a specific type of information.

• SegmentsA segment is a set of extents allocated for a certain logical

structure. The different types of segments are :1.Data segment – stores table data2.Index segment – stores index data3.Temporary segment – temporary space used during SQL

execution4.Rollback Segment – stores undo information

Page 18: Oracle 10g Introduction 1

• SchemaA schema is a collection of database objects. A schema is

owned by a database user and has the same name as that user. Schema objects are the logical structures that directly refer to the database's data. Schema objects include structures like tables, views, and indexes

Page 19: Oracle 10g Introduction 1
Page 20: Oracle 10g Introduction 1

The Oracle Server architecture can be described in three categories:•User-related processes•Logical memory structures that are collectively called an Oracle instance•Physical file structures that are collectively called a database

Page 21: Oracle 10g Introduction 1

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.

Page 22: Oracle 10g Introduction 1
Page 23: Oracle 10g Introduction 1

User Processes

• User Processes initiates connection• Maintaining connection in a session

Page 24: Oracle 10g Introduction 1
Page 25: Oracle 10g Introduction 1

Program Global Area (PGA

• PGA is a memory buffer that contains data and control information for a server process• PGA is created by oracle when a server process is started• PGA area is a non-shared area of memory created by

oracle when a server process is started.

Page 26: Oracle 10g Introduction 1
Page 27: Oracle 10g Introduction 1

System Global Area (SGA)

• System Global Area (SGA) is a shared memory region that contains data and co ntrol information for one Oracle instance• Oracle allocates the SGA when an instance starts and

deallocates it when the instance shuts down• Each instance has its own SGA

Page 28: Oracle 10g Introduction 1

SGA Memory Structure

• Buffer CacheDatabase buffers store the most recently used blocks of

data. The set of database buffers in an instance is the database buffer cache.• Redo Log BufferRedo log buffer stores redo entries—a log of changes

made to the database• Shared PoolShared pool contains shared memory constructs, such as

shared SQL areas

Page 29: Oracle 10g Introduction 1

Oracle Background Process

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. Processes are jobs that work in the memory of these computers.

Page 30: Oracle 10g Introduction 1

Oracle Background Process (cont.)• System Monitor – SMON• This database background process performs instance

recovery at the start of the database. SMON also cleans up temporary segments that are no longer in use and recovers dead transactions skipped during crash and instance recovery because of file-read or offline errors. It coalesces i.e. combines contiguous free extents into larger free extents.

• Process Monitor - PMON• This database background process cleans up failed

user processes. PMON is responsible for releasing the lock i.e. cleaning up the cache and freeing resources that the process was using. Its effect can be seen when a process holding a lock is killed.

Page 31: Oracle 10g Introduction 1

Oracle Background Process (cont.)• Database Writer - DBWR• This background process is responsible for managing

the contents of the data block buffer cache and dictionary cache. DBWR performs batch writes of changed block. Since Oracle uses write-ahead logging, DBWR does not need to write blocks when a transaction commits.

• Recover - RECO• The recover process automatically cleans up failed or

suspended distributed transactions.

Page 32: Oracle 10g Introduction 1

Oracle Background Process (cont.)• Log Writer - LGWR• This background process manages the writing of the

contents of the redo log buffer to the online redo log files. LGWR writes the log entries in batch form. The Redo log buffers entries always contain the most up-to-date status of the database.

• Archiver - ARCH• The Archiver process reads the redo log files once Oracle

has filled them and writes a copy of the used redo log files to the specified archive log destination(s). Actually, for most databases, ARCH has no effect on the overall system performance. On some large database sites, however, archiving can have an impact on system performance.

Page 33: Oracle 10g Introduction 1

Oracle Background Process (cont.)• Checkpoint - CKPT• All modified information in database buffer in the SGA is written

to the datafiles by a database write process (DBWR). This event indicates a checkpoint. The checkpoint process is responsible for signaling DBWR at checkpoints and updating all of the datafiles and control files of the database.

• Job Queue Processes• Job queue processes are used for batch processing. They run user

jobs. They can be viewed as a scheduler service that can be used to schedule jobs as PL/SQL statements or procedures on an Oracle instance. Given a start date and an interval, the job queue processes try to run the job at the next occurrence of the interval.

Page 34: Oracle 10g Introduction 1

Q & A