Mastering Oracle SQL
If you write programs to run against an Oracle database, you spend a lot of time and mental energy writing queries to return the data your programs need. Knowledge of SQL, and particularly of Oracle's implementation of SQL, is the key to writing good queries in a timely manner. In this book, the authors share their knowledge of Oracle SQL, and show you many creative techniques that you can use to advantage in your own applications. This book shows you how to: leverage Oracle's vast library of built-in SQL functions; query time-based data, and write joins involving date and time ranges; use Oracle SQL's hierarchical query features to deal with data best represented in a tree format; use DECODE and CASE to implement conditional logic in your queries; use Oracle's new, analytic SQL features to write ranking queries, lag and lead queries, and windowing queries; and join data from two or more tables using the newly supported SQL92 join syntax. In addition, you'll see how SQL can best be integrated with PL/SQL. You'll also learn various best practices to help you write SQL queries that perform efficiently.
- Paperback | 320 pages
- 174.2 x 240.3 x 21.6mm | 508.03g
- 17 Apr 2002
- O'Reilly Media, Inc, USA
- Sebastopol, United States
Table of contents
Preface 1. Introduction to SQL What Is SQL? A Brief History of SQL A Simple Database DML Statements 2. The WHERE Clause Life Without WHERE WHERE to the Rescue WHERE Clause Evaluation Conditions and Expressions WHERE to Go from Here 3. Joins Inner Joins Outer Joins Self Joins Joins and Subqueries DML Statements on a Join View ANSI-Standard Join Syntax in Oracle9i 4. Group Operations Aggregate Functions The GROUP BY Clause The HAVING Clause 5. Subqueries What Is a Subquery? Noncorrelated Subqueries Correlated Subqueries Inline Views Subquery Case Study: The Top N Performers 6. Handling Temporal Data Internal DATE Storage Format Getting Dates In and Out of a Database Date Manipulation Oracle9i New DATETIME Features INTERVAL Literals 7. Set Operations Set Operators Using Set Operations to Compare Two Tables Using NULLs in Compound Queries Rules and Restrictions on Set Operations 8. Hierarchical Queries Representing Hierarchical Information Simple Hierarchy Operations Oracle SQL Extensions Complex Hierarchy Operations Restrictions on Hierarchical Queries 9. DECODE and CASE DECODE, NVL, and NVL2 The Case for CASE DECODE and CASE Examples 10. Partitions, Objects, and Collections Table Partitioning Objects and Collections 11. PL/SQL What Is PL/SQL? Procedures, Functions, and Packages Calling Stored Functions from Queries Restrictions on Calling PL/SQL from SQL Stored Functions in DML Statements The SQL Inside Your PL/SQL 12. Advanced Group Operations ROLLUP CUBE The GROUPING Function GROUPING SETS Oracle9i Grouping Features The GROUPING_ID and GROUP_ID Functions 13. Advanced Analytic SQL Analytic SQL Overview Ranking Functions Windowing Functions Reporting Functions Summary 14. SQL Best Practices Know When to Use Specific Constructs Avoid Unnecessary Parsing Consider Literal SQL for Decision Support Systems
About Sanjay Mishra
Sanjay Mishra is a certified Oracle database administrator with more than ten years of IT experience. He has been involved in the design, architecture, and implementation of many mission-critical and decision support databases. He has worked extensively in the areas of database architecture, database management, backup / recovery, performance tuning, Oracle Parallel Server, and parallel execution. He has a Bachelor of Science degree in Electrical Engineering, and a Master of Engineering degree in Systems Science and Automation. He is the coauthor of Oracle Parallel Processing and Oracle SQL Loader: The Definitive Guide (both published by O'Reilly & Associates). Presently, he works as a database architect at Dallas Based i2 Technologies, and can be reached at firstname.lastname@example.org. Alan Beaulieu has been designing, building, and implementing custom database applications for over 13 years. He currently runs his own consulting company that specializes in designing Oracle databases and supporting services in the fields of Financial Services and Telecommunications. In building large databases for both OLTP and OLAP environments, Alan utilizes such Oracle features as Parallel Query, Partitioning, and Parallel Server. Alan has a Bachelor of Science degree in Operations Research from the Cornell University School of Engineering. He lives in Massachusetts with his wife and two daughters and can be reached at email@example.com.