Oracle® Database Concepts 11g Release 2 (11.2) E10713-02 August 2009 Oracle Database Concepts, 11g Release 2 (11.2) E10713-02 Copyright © 1993, 2009, Oracle and/or its affiliates. All rights reserved. Primary Authors: Lance Ashdown, Tom Kyte Contributors: Drew Adams, David Austin, Vladimir Barriere, Hermann Baer, David Brower, Jonathan Creighton, Bjørn Engsig, Steve Fogel, Bill Habeck , Bill Hodak, Yong Hu, Pat Huey, Vikram Kapoor, Feroz Khan, Jonathan Klein, Sachin Kulkarni, Paul Lane, Adam Lee, Yunrui Li , Bryn Llewellyn, Rich Long, Barb Lundhild, Neil Macnaughton, Vineet Marwah, Mughees Minhas, Sheila Moore, Valarie Moore, Gopal Mulagund, Paul Needham, Gregory Pongracz, John Russell, Vivian Schupmann, Shrikanth Shankar, Cathy Shea, Susan Shepard, Jim Stenoish, Juan Tellez, Lawrence To, Randy Urbano, Badhri Varanasi, Simon Watt, Steve Wertheimer, Daniel Wong This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this software or related documentation is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle USA, Inc., 500 Oracle Parkway, Redwood City, CA 94065. This software is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications which may create a risk of personal injury. If you use this software in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure the safe use of this software. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software in dangerous applications. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. This software and documentation may provide access to or information on content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services. iii Contents Preface xiii Audience xiii Documentation Accessibility xiii Related Documentation xiv Conventions xiv 1 Introduction to Oracle Database A Brief Introduction to Relational Databases 1-1 Database Management System (DBMS) 1-1 The Relational Model 1-2 Relational Database Management System (RDBMS) 1-2 A Brief History of Oracle Database 1-3 Schema Objects 1-4 Tables 1-4 Indexes 1-4 Data Access 1-5 Structured Query Language (SQL) 1-5 PL/SQL and Java 1-5 Transaction Management 1-6 Transactions 1-6 Data Concurrency 1-6 Data Consistency 1-7 Oracle Database Architecture 1-7 Database and Instance 1-7 Database Storage Structures 1-8 Database Instance Structures 1-9 Application and Networking Architecture 1-10 Oracle Database Documentation Roadmap 1-12 Basic Group 1-12 Intermediate Group 1-12 Advanced Group 1-13 Part I Oracle Relational Data Structures iv 2 Tables and Table Clusters Introduction to Schema Objects 2-1 Schema Object Types 2-2 Schema Object Storage 2-3 Schema Object Dependencies 2-4 SYS and SYSTEM Schemas 2-5 Sample Schemas 2-6 Overview of Tables 2-6 Columns and Rows 2-7 Example: CREATE TABLE and ALTER TABLE Statements 2-7 Oracle Data Types 2-9 Integrity Constraints 2-14 Object Tables 2-15 Temporary Tables 2-15 External Tables 2-16 Table Storage 2-18 Overview of Table Clusters 2-20 Overview of Indexed Clusters 2-21 Overview of Hash Clusters 2-23 3 Indexes and Index-Organized Tables Overview of Indexes 3-1 Index Characteristics 3-2 B-Tree Indexes 3-5 Bitmap Indexes 3-11 Function-Based Indexes 3-16 Application Domain Indexes 3-17 Index Storage 3-18 Overview of Index-Organized Tables 3-18 Index-Organized Table Characteristics 3-19 Index-Organized Tables with Row Overflow Area 3-21 Secondary Indexes on Index-Organized Tables 3-21 4 Partitions, Views, and Other Schema Objects Overview of Partitions 4-1 Partition Characteristics 4-2 Partitioned Tables 4-7 Partitioned Indexes 4-7 Partitioned Index-Organized Tables 4-12 Overview of Views 4-12 Characteristics of Views 4-13 Updatable Join Views 4-15 Object Views 4-16 Overview of Materialized Views 4-16 Characteristics of Materialized Views 4-17 Refresh Methods for Materialized Views 4-18 v Query Rewrite 4-19 Overview of Sequences 4-20 Sequence Characteristics 4-20 Concurrent Access to Sequences 4-20 Overview of Dimensions 4-21 Hierarchical Structure of a Dimension 4-21 Creation of Dimensions 4-21 Overview of Synonyms 4-22 5 Data Integrity Introduction to Data Integrity 5-1 Techniques for Guaranteeing Data Integrity 5-1 Advantages of Integrity Constraints 5-1 Types of Integrity Constraints 5-2 NOT NULL Integrity Constraints 5-3 Unique Constraints 5-3 Primary Key Constraints 5-5 Foreign Key Constraints 5-6 Check Constraints 5-9 States of Integrity Constraints 5-10 Checks for Modified and Existing Data 5-10 Deferrable Constraints 5-11 Examples of Constraint Checking 5-12 6 The Data Dictionary and Dynamic Performance Views Overview of the Data Dictionary 6-1 Contents of the Data Dictionary 6-2 Storage of the Data Dictionary 6-4 How Oracle Database Uses the Data Dictionary 6-4 Overview of the Dynamic Performance Views 6-5 Contents of the Dynamic Performance Views 6-6 Storage of the Dynamic Performance Views 6-6 Database Object Metadata 6-6 Part II Oracle Data Access 7 SQL Introduction to SQL 7-1 SQL Data Access 7-1 SQL Standards 7-2 Overview of SQL Statements 7-3 Data Definition Language (DDL) Statements 7-3 Data Manipulation Language (DML) Statements 7-4 Transaction Control Statements 7-8 Session Control Statements 7-8 System Control Statement 7-9 vi Embedded SQL Statements 7-9 Overview of the Optimizer 7-10 Use of the Optimizer 7-10 Optimizer Components 7-11 Access Paths 7-12 Optimizer Statistics 7-13 Optimizer Hints 7-14 Overview of SQL Processing 7-15 Stages of SQL Processing 7-15 How Oracle Database Processes DML 7-22 How Oracle Database Processes DDL 7-23 8 Server-Side Programming: PL/SQL and Java Introduction to Server-Side Programming 8-1 Overview of PL/SQL 8-2 PL/SQL Subprograms 8-3 PL/SQL Packages 8-6 PL/SQL Anonymous Blocks 8-9 PL/SQL Language Constructs 8-9 PL/SQL Collections and Records 8-10 How PL/SQL Runs 8-11 Overview of Java in Oracle Database 8-12 Overview of the Java Virtual Machine (JVM) 8-13 Java Programming Environment 8-14 Overview of Triggers 8-16 Advantages of Triggers 8-17 Types of Triggers 8-17 Timing for Triggers 8-18 Creation of Triggers 8-18 Execution of Triggers 8-21 Storage of Triggers 8-21 Part III Oracle Transaction Management 9 Transactions Introduction to Transactions 9-1 Sample Transaction: Account Debit and Credit 9-2 Structure of a Transaction 9-2 Statement-Level Atomicity 9-4 System Change Numbers (SCNs) 9-5 Overview of Transaction Control 9-6 Transaction Names 9-7 Active Transactions 9-7 Savepoints 9-8 Rollback of Transactions 9-10 Committing Transactions 9-10 vii Overview of Autonomous Transactions 9-11 Overview of Distributed Transactions 9-12 Two-Phase Commit 9-13 In-Doubt Transactions 9-13 10 Data Concurrency and Consistency Introduction to Data Concurrency and Consistency 10-1 Multi-Versioning Read Consistency 10-2 Locking Mechanisms 10-5 ANSI/ISO Transaction Isolation Levels 10-5 Overview of Oracle Database Transaction Isolation Levels 10-6 Read Committed Isolation 10-6 Serializable Isolation 10-8 Read-Only Isolation 10-11 Overview of the Oracle Database Locking Mechanism 10-11 Summary of Locking Behavior 10-12 Use of Locks 10-12 Lock Modes 10-15 Lock Conversion and Escalation 10-15 Lock Duration 10-16 Locks and Deadlocks 10-16 Overview of Automatic Locks 10-17 DML Locks 10-18 DDL Locks 10-24 System Locks 10-25 Overview of Manual Data Locks 10-26 Overview of User-Defined Locks 10-27 Part IV Oracle Database Storage Structures 11 Physical Storage Structures Introduction to Physical Storage Structures 11-1 Mechanisms for Storing Database Files 11-2 Oracle Automatic Storage Management (Oracle ASM) 11-3 Oracle-Managed and User-Managed Files 11-6 Overview of Data Files 11-7 Use of Data Files 11-7 Permanent and Temporary Data Files 11-8 Online and Offline Data Files 11-9 Data File Structure 11-9 Overview of Control Files 11-10 Use of Control Files 11-10 Multiple Control Files 11-11 Control File Structure 11-11 Overview of the Online Redo Log 11-12 Use of the Online Redo Log 11-12 viii How Oracle Database Writes to the Online Redo Log 11-12 Structure of the Online Redo Log 11-15 12 Logical Storage Structures Introduction to Logical Storage Structures 12-1 Logical Storage Hierarchy 12-2 Logical Space Management 12-2 Overview of Data Blocks 12-5 Data Blocks and Operating System Blocks 12-5 Data Block Format 12-6 Data Block Compression 12-10 Space Management in Data Blocks 12-10 Overview of Extents 12-16 Allocation of Extents 12-16 Deallocation of Extents 12-18 Storage Parameters for Extents 12-18 Overview of Segments 12-19 User Segments 12-19 Temporary Segments 12-21 Undo Segments 12-22 ASSM and the High Water Mark 12-22 Overview of Tablespaces 12-25 Use of Tablespaces 12-25 Tablespace Characteristics 12-25 System Tablespaces 12-27 Undo Tablespaces 12-28 Temporary Tablespaces 12-29 Part V Oracle Instance Architecture 13 The Oracle Database Instance Introduction to the Oracle Database Instance 13-1 Database Instance Structure 13-1 Database Instance Configurations 13-2 Overview of Instance Startup and Shutdown 13-5 Overview of Instance and Database Startup 13-5 Overview of Database and Instance Shutdown 13-8 Overview of Checkpoints 13-11 Purpose of Checkpoints 13-11 When Oracle Database Initiates Checkpoints 13-11 Overview of Instance Recovery 13-12 Purpose of Instance Recovery 13-12 When Oracle Database Performs Instance Recovery 13-12 Importance of Checkpoints for Instance Recovery 13-13 Instance Recovery Phases 13-14 Overview of Parameter Files 13-15 ix Initialization Parameters 13-15 Server Parameter Files 13-16 Text Initialization Parameter Files 13-16 Modification of Initialization Parameter Values 13-17 Overview of Diagnostic Files 13-18 Automatic Diagnostic Repository 13-19 Alert Log 13-21 Trace Files 13-22 14 Memory Architecture Introduction to Oracle Database Memory Structures 14-1 Basic Memory Structures 14-1 Oracle Database Memory Management 14-3 Overview of the User Global Area 14-3 Overview of the Program Global Area 14-4 Contents of the PGA 14-5 PGA Usage in Dedicated and Shared Server Modes 14-7 Overview of the System Global Area 14-7 Database Buffer Cache 14-8 Redo Log Buffer 14-12 Shared Pool 14-13 Large Pool 14-19 Java Pool 14-20 Streams Pool 14-21 Fixed SGA 14-21 Overview of Software Code Areas 14-21 15 Process Architecture Introduction to Processes 15-1 Multiple-Process Oracle Database Systems 15-1 Types of Processes 15-2 Overview of Client Processes 15-3 Client and Server Processes 15-3 Connections and Sessions 15-4 Overview of Server Processes 15-6 Dedicated Server Processes 15-6 Shared Server Processes 15-6 Overview of Background Processes 15-7 Mandatory Background Processes 15-7 Optional Background Processes 15-11 Slave Processes 15-13 16 Application and Networking Architecture Overview of Oracle Application Architecture 16-1 Overview of Client/Server Architecture 16-1 Overview of Multitier Architecture 16-3 x Overview of Grid Architecture 16-5 Overview of Oracle Networking Architecture 16-5 How Oracle Net Services Works 16-6 The Oracle Net Listener 16-6 Dedicated Server Architecture 16-8 Shared Server Architecture 16-10 Database Resident Connection Pooling 16-12 Overview of the Program Interface 16-13 Program Interface Structure 16-14 Program Interface Drivers 16-14 Communications Software for the Operating System 16-14 Part VI Oracle Database Administration and Development 17 Topics for Database Administrators and Developers Introduction to Common Database Topics 17-1 Overview of Database Security 17-1 User Accounts 17-1 Authentication 17-3 Encryption 17-4 Access Control 17-4 Monitoring 17-5 Overview of High Availability 17-6 High Availability and Unplanned Downtime 17-6 High Availability and Planned Downtime 17-10 Overview of Grid Computing 17-12 Database Server Grid 17-13 Database Storage Grid 17-14 Overview of Data Warehousing and Business Intelligence 17-15 Data Warehousing and OLTP 17-15 Data Warehouse Architecture 17-16 Overview of Extraction, Transformation, and Loading (ETL) 17-18 Business Intelligence 17-19 Overview of Oracle Information Integration 17-20 Federated Access 17-21 Information Sharing 17-22 18 Concepts for Database Administrators Duties of Database Administrators 18-1 Tools for Database Administrators 18-2 Oracle Enterprise Manager 18-2 SQL*Plus 18-4 Tools for Database Installation and Configuration 18-4 Tools for Oracle Net Configuration and Administration 18-4 Tools for Data Movement and Analysis 18-5 Topics for Database Administrators 18-8 [...]... developers 1-12 Oracle Database Concepts Oracle Database Documentation Roadmap Table 1–1 Intermediate Group: 2 Day + Guides Database Administrators Database Developers Oracle Database 2 Day + Performance Tuning Guide Oracle Database 2 Day + Application Express Developer's Guide Oracle Database 2 Day + Real Application Clusters Guide Oracle Database 2 Day + Java Developer's Guide Oracle Database 2 Day + Data... Oracle Database Instance" Database Storage Structures An essential task of a relational database is data storage This section briefly describes the physical and logical storage structures used by Oracle Database 1-8 Oracle Database Concepts Oracle Database Architecture Physical Storage Structures The physical database structures are the files that store the data When you execute the SQL command CREATE DATABASE, ... and developers at one time or another Table 1–2 Advanced Group Database Administrators Database Developers Oracle Database Administrator's Guide Oracle Database Advanced Application Developer's Guide Oracle Database Performance Tuning Guide Oracle Database PL/SQL Language Reference Oracle Database Backup and Recovery User's Guide Oracle Database PL/SQL Packages and Types Reference Oracle Real Application... which a database application connects to an Oracle database The two most common database architectures are client/server and multitier 1-10 Oracle Database Concepts Oracle Database Architecture In a client/server architecture, the client application initiates a request for an operation to be performed on the database server The server runs Oracle Database software and handles the functions required... least one database instance (commonly referred to as simply an instance) Because an instance and a database are so closely connected, the term Oracle database is sometimes used to refer to both instance and database In the strictest sense the terms have the following meanings: ■ Database A database is a set of files, located on disk, that store data These files can exist independently of a database. .. Oracle database has one or more physical data files, which contain all the database data The data of logical database structures, such as tables and indexes, is physically stored in the data files ■ Control files Every Oracle database has a control file A control file contains metadata specifying the physical structure of the database, including the database name and the names and locations of the database. .. also stored in the database and can be created and manipulated with SQL statements but are not contained in a schema These objects include database users, roles, contexts, and directory objects 2-2 Oracle Database Concepts Introduction to Schema Objects See Also: ■ ■ Oracle Database 2 Day DBA and Oracle Database Administrator's Guide to learn how to manage schema objects Oracle Database SQL Language... Information in this manual applies to the Oracle database server running on all operating systems This preface contains these topics: ■ Audience ■ Documentation Accessibility ■ Related Documentation ■ Conventions Audience Oracle Database Concepts is intended for technical users, primarily database administrators and database application developers, who are new to Oracle Database Typically, the reader of this... read with the following manuals: ■ Oracle Database 2 Day DBA ■ Oracle Database 2 Day Developer's Guide For more related documentation, see "Oracle Database Documentation Roadmap" on page 1-12 Many books in the Oracle Database documentation set use the sample schemas of the seed database, which is installed by default when you install Oracle Refer to Oracle Database Sample Schemas for information on... that you enter 1 Introduction to Oracle Database 1 This chapter provides an overview of Oracle Database This chapter contains the following sections: ■ A Brief Introduction to Relational Databases ■ Schema Objects ■ Data Access ■ Transaction Management ■ Oracle Database Architecture ■ Oracle Database Documentation Roadmap A Brief Introduction to Relational Databases Every organization has information . Oracle® Database Concepts 11g Release 2 (11.2) E10713-02 August 2009 Oracle Database Concepts, 11g Release 2 (11.2) E10713-02 Copyright. Conventions Audience Oracle Database Concepts is intended for technical users, primarily database administrators and database application developers, who are new to Oracle Database.