Database Architecture Overview Oracle 11g Server Architecture • • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Transactions Data Dictionary Schema And Users Oracle Server Architecture An Oracle server: • Is a database management system that provides an open, comprehensive, integrated approach to information management • Consists of an Oracle instance and an Oracle database Oracle Server Overview of Primary Components User process Instance Shared pool Library cache Server process Data Dict. cache SGA Redo log Database buffer cache buffer cache PGA PMON SMON DBWR LGWR Parameter file Password file Data files Control files CKPT Redo log files Database Others Archived log files Oracle 11g Server Architecture • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Data Dictionary Schema And Users Oracle Instance • Is a means to access an Oracle database • Always opens one and only one database • Consists of memory and process structures Instance Shared pool Library cache Data Dictionary cache SGA Database Redo log buffer cache buffer cache PMON SMON DBWR LGWR CKPT Others Memory structures Background structures Oracle 11g Server Architecture • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Data Dictionary Schema And Users Physical Structure The physical structure of an Oracle database is determined by the operating system files that provide the actual physical storage for database information. • Control files • Data files Header Control • Redo log files Online redo log files) Data files (includes data dictionary) files Oracle 11g Server Architecture • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Data Dictionary Schema And Users Database Files • • • • • Parameter Files Control Files Data Files Redo Log Files Undo Data Files Oracle Database Oracle Database Parameter file Password file Data files Control files Redo log files Archived log files Database Files • • • • • Parameter Files Control Files Data Files Redo Log Files Undo Data Files Parameter Files • Entries are specific to the instance being accessed • There are two kinds of parameters: • Explicit: Having an entry in the file • Implicit: No entry within the file, but assuming the Oracle default values • Multiple files can be used for a single database to optimize performance in different situations. SPFILE spfileSID.ora • Binary file with the ability to make changes persistent across shutdown and startup • Maintained by the Oracle server • Records parameter value changes made with the ALTER SYSTEM command • Can specify whether the change being made is temporary or persistent • Values can be deleted or reset to allow an instance to revert to the default value • Can be dumped to text file for manual editing Database Files • • • • • Parameter Files Control Files Data Files Redo Log Files Undo Data Files Control File The control file is a binary file that defines the current state of the physical database.. • Loss of the control file requires recovery • Is read at MOUNT stage • Is required to operate • Is linked to a single database • Should be multiplexed • Maintains integrity of database • Sized initially by CREATE DATABASE Database Control files Database Files • • • • • Parameter Files Control Files Data Files Redo Log Files Undo Data Files Database Files • Parameter Files • Control Files • Data Files • • • • • • Tablespaces Oracle Managed Files Data Block Data Types Tables Indexes • Redo Log Files • Undo Data Files Logical Structure The logical structure of the Oracle architecture dictates how the physical space of a database is to be used. A hierarchy exists in this structure that consists of tablespaces, segments, extents, and blocks. Tablespace Data file Segment Extent Segment Blocks SYSTEM and Non-SYSTEM Tablespaces • SYSTEM tablespace: • • • Created with the database Contains the data dictionary Contains the SYSTEM undo segment • Non-SYSTEM tablespaces: • • • Separate segments Ease space administration Control amount of space allocated to a user Database Files • Parameter Files • Control Files • Data Files • • • Tablespaces Oracle Managed Files Data Block • Data Types • Tables • Indexes • Redo Log Files • Undo Data Files Oracle Managed Files • Oracle Managed Files (OMF) simplify file administration by eliminating the need to directly manage the files in an Oracle database • This feature has two major thrusts: • • Allows database objects to be created without specifying the underlying operating system files Automatically removes obsolete data files and online redo logs Database Files • Parameter Files • Control Files • Data Files • • • • • • Tablespaces Oracle Managed Files Data Block Data Types Tables Indexes • Redo Log Files • Undo Data Files Database Block • Minimum unit of I/O • Consists of one or more OS blocks • Set at tablespace creation • DB_BLOCK_SIZE is the default block size Database Files • Parameter Files • Control Files • Data Files • • • • • • Tablespaces Oracle Managed Files Data Block Data Types Tables Indexes • Redo Log Files • Undo Data Files Oracle data types Data type User-defined Scalar CHAR(N), NCHAR(N) VARCHAR2(N), NVARCHAR2(N) NUMBER(P,S) DATE RAW(N) BLOB, CLOB, NCLOB, BFILE LONG, LONG RAW ROWID Built-in Collection VARRAY TABLE Relationship REF System-Provided Datatypes Built-In Datatype Native Datatypes CHARACTER NUMBER Extended Datatypes Support Datatypes Text ANSI Image DB2 DATE Video SQL/DS LOB RAW ROWID Audio PL/SQL Datatypes Spatial BOOLEAN XML Time Series BINARY_INTEGER Database Files • Parameter Files • Control Files • Data Files • • • • • • Tablespaces Oracle Managed Files Data Block Data Types Tables Indexes • Redo Log Files • Undo Data Files Tables in Oracle Regular table Index-organized table Partitioned table Cluster Database Files • Parameter Files • Control Files • Data Files • • • • • • Tablespaces Oracle Managed Files Data Block Data Types Tables Indexes • Redo Log Files • Undo Data Files Classification of Indexes • Logical • • • • Single column or concatenated Unique or nonunique Function Based Domain Based • Physical • Partitioned or nonpartitioned • B-tree • Normal or reverse key • Bitmap • Bitmap Join Index Database Files • • • • • Parameter Files Control Files Data Files Redo Log Files Undo Data Files Using Redo Log Files Redo log files record all changes made to data and provide a recovery mechanism from a system or media failure. • Redo log files are organized into groups. • An Oracle database requires at least two groups. • Each redo log within a group is called a member. Database Redo log files Structure of Redo Log Files Group 1 Group 2 Group 3 Disk 1 Member Member Member Member Member Member Disk 2 How Redo Logs Work • Redo logs are used in a cyclic fashion. • When a redo log file is full, LGWR will move to the next log group. • This is called a log switch • Checkpoint operation also occurs • Information is written to the control file Database Files • • • • • Parameter Files Control Files Data Files Redo Log Files Undo Data Files Undo Data Overview • Before Oracle makes a change to a database block it is copied to the Undo area. • Used for Rollback and Read Consistency. Oracle 11g Server Architecture • • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Transactions Data Dictionary Schema And Users Process Structure An Oracle process is a program that depending on its type can request information, execute a series of steps, or perform a specific task. On some OS (MS Windows…) these are actually implemented as process threads. Oracle takes advantage of various types of processes: • User process: Started at the time a database user requests connection to the Oracle server • Server process: Connects to the Oracle Instance and is started when a user establishes a session. • Background process: Available when an Oracle instance is started Background Processes The relationship between the physical and memory structures is maintained and enforced by Oracle’s background processes. • Mandatory background processes DBWn LGWR PMON SMON CKPT and others • Optional background processes ARCn QMNn CJQ0 LCKn LMON LMDn Pnnn Dnnn Snnn RECO and others Oracle 11g Server Architecture • • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Transactions Data Dictionary Schema And Users Memory Structure Oracle’s memory structure consists of two memory areas known as: • System Global Area (SGA): Allocated at instance startup, and is a fundamental component of an Oracle Instance • Program Global Area (PGA): Allocated when the server process is started System Global Area (SGA) • The SGA consists of several memory structures: • Shared pool • Database buffer cache • Redo log buffer • Other structures (e.g. lock and latch management, statistical data) System Global Area (SGA) • SGA is dynamic and sized using MEMORY_TARGET without shutting down the instance • SGA memory allocated and tracked in granules by SGA components • Contiguous virtual memory allocation • Size based on MEMORY_TARGET Program Global Area (PGA) The PGA is memory reserved for each user process that connects to an Oracle database. Managed as part of the MEMORY_TARGET PGA Server process Dedicated server Session Stack information space sort area, cursor information User process SGA Shared server Stack sort area, cursor information space SGA Session information Shared SQL areas Shared SQL areas Oracle 11g Server Architecture • • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Transactions Data Dictionary Schema And Users Transactions • Oracle has an implicit transaction model. • A transaction starts immediately after the last one completes • Can be made READ-ONLY via ALTER TRANSACTION command • COMMIT or ROLLBACK ends transaction Oracle’s Multi-Version Concurrency Read Consistent Row Locking With Oracle … report • Updates don’t lockout reports and reports don’t lockout updates Budget Table • Reports see only committed data via Multi-Versioning update Undo Tablespace Before Image accurate report • Queries yield maximum throughput with correct results no waiting and no dirty reads! • Row locks never escalate - the most scaleable solution available Multi Version Read Consistency High Throughput Concurrency Performance Table stakes Oracle Microsoft Sybase Unique Concurrency Model Yes No No Readers Don’t Block Writers Yes No* No Writers Don’t Block Readers Yes No* No Guarantees Consistent Queries Yes Yes No Eliminates Lock Escalation Yes No No Reduces Deadlocks under Load Yes No No Oracle does not compromise data accuracy for greater concurrency *Except when using Snapshots in SS 2005 Oracle 11g Server Architecture • • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Transactions Data Dictionary Schema And Users Data Dictionary During database creation, the Oracle server creates additional object structures within the data files. • Data dictionary tables • Dynamic performance tables Data files Control files Redo log files Database Data Dictionary Tables Dynamic Performance Tables Data Dictionary The data dictionary is a set of read-only tables and views that record, verify, and provide information about its associated database. • Describes the database and its objects • Includes two types of objects: • Base tables • Store description of database • Created with CREATE DATABASE • Data Dictionary views • Summarize base table information • Created using catalog.sql script Data Dictionary Contents The data dictionary provides information about: • Logical and physical database structure • Definitions and space allocations of objects • Integrity constraints • Users • Roles • Privileges • Auditing Data Dictionary View Categories The data dictionary consists of three main sets of static views distinguished from each other by their scope: • DBA: What is in all the schemas • ALL: What the user can access • USER: What is in the user's schema DBA_xxx All of the objects in the database ALL_xxx Objects accessible by the current user USER_xxx Objects owned by the current user Oracle 11g Server Architecture • • • • • • • Oracle Instance Oracle Database Database Files Server Processes Memory Structures Data Dictionary Schema And Users Database Schema • • • • • A schema is a named collection of objects A user is created, and a corresponding schema can be created User can be associated only with one schema Username and schema are often used interchangeably Users are not necessarily associated with a schema Schema Objects Tables Triggers Constraints Indexes Views Sequences Stored program units Synonyms User-defined data types Database links Oracle 11g Server Architecture • An Oracle server consists of an Oracle instance and an Oracle database • An Oracle instance consists of several required and some more optional processes (threads) • An Oracle database is built using different file types QUESTIONS ANSWERS