You are previewing Pro Oracle SQL, Second Edition.
O'Reilly logo
Pro Oracle SQL, Second Edition

Book Description

Pro Oracle SQL, Second Edition unlocks the power of SQL in the Oracle database—one of the most potent SQL implementations on the market today. To master it requires a multi-pronged approach: learn the language features, learn how and why the language features work, learn the supporting features that Oracle provides to help use the language effectively, and learn to think and work in sets.

Karen Morton has updated the content for Oracle version 12c and helps you master powerful aspects of Oracle SQL from the inside-out. You'll learn analytic functions, the MODEL clause, and advanced grouping syntax—features that will help in creating good queries for reporting and business intelligence applications. Pro Oracle SQL, Second Edition also helps you minimize parsing overhead, read execution plans, test for correct results, understand performance management, and exert control over SQL execution in your database. You'll learn when to create indexes, how to verify that they make a difference, how to use SQL Baselines and Profiles to optimize and stabilize SQL execution plans, and much more. You'll also understand how SQL is optimized for working in sets, and that the key to getting accurate results lies in making sure that queries ask clear and precise questions.

Pro Oracle SQL, Second Edition helps you work at a truly professional level in the Oracle dialect of SQL. You'll master the language, the tools to work effectively with the language, and the right way to think about a problem in SQL.

  • Endorsed by the OakTable Network, a group of Oracle technologists well-known for their rigorous and scientific approach to Oracle Database performance

  • Comprehensive—goes beyond the language with a focus on what you need to know to write successful queries and data manipulation statements.

  • Performance focused—teaches you how to measure the performance of your SQL statements and not just the syntax.

What you'll learn

  • Master powerful SQL features implemented in the Oracle Database

  • Understand how the Oracle Optimizer develops execution plans

  • Read and interpret SQL execution plans

  • Quickly diagnose and fix badly performing SQL

  • Control execution plans through hints, profiles, and plan baselines

  • Optimize queries within packaged applications without touching the code

  • Recognize when not to waste time on SQL that is performing optimally

Who this book is for

Pro Oracle SQL, Second Edition is aimed at developers and database administrators who submit SQL for execution by an Oracle database. Readers should already know the basic four SQL statements, and be ready to learn deeply about Oracle's specific implementation of the language, including Oracle-specific features and syntax. Readers should also want to learn about Oracle Database features such as analytic queries, the MODEL clause, and the WITH clause (subquery factoring) that are designed to help developers and database administrators exert control over their SQL environment and its execution.

Table of Contents

  1. Title Page
  2. Contents at a Glance
  3. Contents
  4. About the Authors
  5. About the Technical Reviewer
  6. Acknowledgments
  7. CHAPTER 1: Core SQL
    1. The SQL Language
    2. Interfacing to the Database
    3. Review of SQL*Plus
    4. The Five Core SQL Statements
    5. The SELECT Statement
    6. The INSERT Statement
    7. The UPDATE Statement
    8. The DELETE Statement
    9. The MERGE Statement
    10. Summary
  8. CHAPTER 2: SQL Execution
    1. Oracle Architecture Basics
    2. SGA: The Shared Pool
    3. The Library Cache
    4. Identical Statements
    5. SGA: The Buffer Cache
    6. Query Transformation
    7. Determining the Execution Plan
    8. Executing the Plan and Fetching Rows
    9. SQL Execution: Putting It All Together
    10. Summary
  9. CHAPTER 3: Access and Join Methods
    1. Full Scan Access Methods
    2. Index Scan Access Methods
    3. Join Methods
    4. Summary
  10. CHAPTER 4: SQL Is about Sets
    1. Thinking in Sets
    2. Set Operations
    3. Sets and Nulls
    4. Summary
  11. CHAPTER 5: It’s about the Question
    1. Asking Good Questions
    2. The Purpose of Questions
    3. Categories of Questions
    4. Questions about the Question
    5. Questions about Data
    6. Building Logical Expressions
    7. Summary
  12. CHAPTER 6: SQL Execution Plans
    1. Explain Plan
    2. Execution Plans
    3. Summary
  13. CHAPTER 7: Advanced Grouping
    1. Basic GROUP BY Usage
    2. HAVING Clause
    3. “New” GROUP BY Functionality
    4. CUBE Extension to GROUP BY
    5. Putting CUBE to Work
    6. Eliminate NULLs with the GROUPING( ) Function
    7. Extending Reports with GROUPING( )
    8. Extending Reports with GROUPING_ID( )
    9. GROUPING SETS ( ) and ROLLUP( )
    10. GROUP BY Restrictions
    11. Summary
  14. CHAPTER 8: Analytic Functions
    1. Overview
    2. Example Data
    3. Anatomy of Analytic Functions
    4. List of Functions
    5. Aggregation Functions
    6. lead and lag
    7. first_value and last_value
    8. Other Analytic Functions
    9. Performance Tuning
    10. Advanced Topics
    11. Organizational Behavior
    12. Summary
  15. CHAPTER 9: The MODEL Clause
    1. Spreadsheets
    2. Interrow Referencing Via the MODEL Clause
    3. Positional and Symbolic References
    4. Returning Updated Rows
    5. Evaluation Order
    6. Aggregation
    7. Iteration
    8. Lookup Tables
    9. NULLs
    10. Performance Tuning with the MODEL Clause
    11. Subquery Factoring
    12. Summary
  16. CHAPTER 10: Subquery Factoring
    1. Standard Usage
    2. WITH Using a PL/SQL Function
    3. Optimizing SQL
    4. Recursive Subqueries
    5. Duplicating CONNECT BY Functionality
    6. Summary
  17. CHAPTER 11: Semijoins and Antijoins
    1. Semijoins
    2. Semijoin Plans
    3. Controlling Semijoin Plans
    4. Semijoin Restrictions
    5. Semijoin Requirements
    6. Antijoins
    7. Antijoin Plans
    8. Controlling Antijoin Plans
    9. Antijoin Restrictions
    10. Antijoin Requirements
    11. Summary
  18. CHAPTER 12: Indexes
    1. Understanding Indexes
    2. Index Structural Types
    3. Partitioned Indexes
    4. Solutions to Match Application Characteristics
    5. Solutions to Management Problems
    6. Summary
  19. CHAPTER 13: Beyond the SELECT
    1. INSERT
    2. UPDATE
    3. DELETE
    4. MERGE
    5. Summary
  20. CHAPTER 14: Transaction Processing
    1. What Is a Transaction?
    2. ACID Properties of a Transaction
    3. Transaction Isolation Levels
    4. Multiversion Read Consistency
    5. Transaction Control Statements
    6. Grouping Operations into Transactions
    7. The Order Entry Schema
    8. The Active Transaction
    9. Using Savepoints
    10. Serializing Transactions
    11. Isolating Transactions
    12. Autonomous Transactions
    13. Summary
  21. CHAPTER 15: Testing and Quality Assurance
    1. Test Cases
    2. Testing Methods
    3. Execution Plan Comparison
    4. Instrumentation
    5. Testing to Destruction
    6. Troubleshooting through Instrumentation
    7. Summary
  22. CHAPTER 16: Plan Stability
    1. Plan Instability: Understanding the Problem
    2. Statistics Feedback
    3. Identifying Plan Instability
    4. Summary
  23. CHAPTER 17: Plan Control
    1. Plan Control: Solving the Problem
    2. Plan Control: Without Access to the Code
    3. Summary
  24. CHAPTER 18: Miscellaneous SQL Constructs
    1. Conditional Logic Constructs
    2. PIVOT/UNPIVOT Queries
    3. SQL to Generate Test Data
    4. Summary
  25. Index