| |
| |
Acknowledgments | |
| |
| |
Introduction | |
| |
| |
| |
Relational Databases and SQL | |
| |
| |
| |
Introduction to Relational Databases and SQL | |
| |
| |
Understand Relational Databases | |
| |
| |
The Relational Model | |
| |
| |
Learn About SQL | |
| |
| |
The SQL Evolution | |
| |
| |
Types of SQL Statements | |
| |
| |
Types of Execution | |
| |
| |
SQL Standard versus Product Implementations | |
| |
| |
| |
Working with the SQL Environment | |
| |
| |
Understand the SQL Environment | |
| |
| |
Understand SQL Catalogs | |
| |
| |
Schemas | |
| |
| |
Schema Objects | |
| |
| |
Then What Is a Database? | |
| |
| |
Name Objects in an SQL Environment | |
| |
| |
Qualified Names | |
| |
| |
Create a Schema | |
| |
| |
Create a Database | |
| |
| |
| |
Creating and Altering Tables | |
| |
| |
Create SQL Tables | |
| |
| |
Specify Column Data Types | |
| |
| |
String Data Types | |
| |
| |
Numeric Data Types | |
| |
| |
Datetime Data Types | |
| |
| |
Interval Data Type | |
| |
| |
Boolean Data Type | |
| |
| |
Using SQL Data Types | |
| |
| |
Create User-Defined Types | |
| |
| |
Specify Column Default Values | |
| |
| |
Delete SQL Tables | |
| |
| |
| |
Enforcing Data Integrity | |
| |
| |
Understand Integrity Constraints | |
| |
| |
Use NOT NULL Constraints | |
| |
| |
Add UNIQUE Constraints | |
| |
| |
Add PRIMARY KEY Constraints | |
| |
| |
Add FOREIGN KEY Constraints | |
| |
| |
The MATCH Clause | |
| |
| |
The [left angle bracket]referential triggered action[right angle bracket] Clause | |
| |
| |
Define CHECK Constraints | |
| |
| |
Defining Assertions | |
| |
| |
Creating Domains and Domain Constraints | |
| |
| |
| |
Creating SQL Views | |
| |
| |
Add Views to the Database | |
| |
| |
Defining SQL Views | |
| |
| |
Create Updateable Views | |
| |
| |
Using the WITH CHECK OPTION Clause | |
| |
| |
Drop Views from the Database | |
| |
| |
| |
Managing Database Security | |
| |
| |
Understand the SQL Security Model | |
| |
| |
SQL Sessions | |
| |
| |
Accessing Database Objects | |
| |
| |
Create and Delete Roles | |
| |
| |
Grant and Revoke Privileges | |
| |
| |
Revoking Privileges | |
| |
| |
Grant and Revoke Roles | |
| |
| |
Revoking Roles | |
| |
| |
| |
Data Access and Modification | |
| |
| |
| |
Querying SQL Data | |
| |
| |
Use a SELECT Statement to Retrieve Data | |
| |
| |
The SELECT Clause and FROM Clause | |
| |
| |
Use the WHERE Clause to Define Search Conditions | |
| |
| |
Defining the WHERE Clause | |
| |
| |
Use the GROUP BY Clause to Group Query Results | |
| |
| |
Use the HAVING Clause to Specify Group Search Conditions | |
| |
| |
Use the ORDER BY Clause to Sort Query Results | |
| |
| |
| |
Modifying SQL Data | |
| |
| |
Insert SQL Data | |
| |
| |
Inserting Values from a SELECT Statement | |
| |
| |
Update SQL Data | |
| |
| |
Updating Values from a SELECT Statement | |
| |
| |
Delete SQL Data | |
| |
| |
| |
Using Predicates | |
| |
| |
Compare SQL Data | |
| |
| |
Using the BETWEEN Predicate | |
| |
| |
Return Null Values | |
| |
| |
Return Similar Values | |
| |
| |
Reference Additional Sources of Data | |
| |
| |
Using the IN Predicate | |
| |
| |
Using the EXISTS Predicate | |
| |
| |
Quantify Comparison Predicates | |
| |
| |
Using the SOME and ANY Predicates | |
| |
| |
Using the ALL Predicate | |
| |
| |
| |
Working with Functions and Value Expressions | |
| |
| |
Use Set Functions | |
| |
| |
Using the COUNT Function | |
| |
| |
Using the MAX and MIN Functions | |
| |
| |
Using the SUM Function | |
| |
| |
Using the AVG Function | |
| |
| |
Use Value Functions | |
| |
| |
Working with String Value Functions | |
| |
| |
Working with Datetime Value Functions | |
| |
| |
Use Value Expressions | |
| |
| |
Working with Numeric Value Expressions | |
| |
| |
Using the CASE Value Expression | |
| |
| |
Using the CAST Value Expression | |
| |
| |
Use Special Values | |
| |
| |
| |
Accessing Multiple Tables | |
| |
| |
Perform Basic Join Operations | |
| |
| |
Using Correlation Names | |
| |
| |
Creating Joins with More than Two Tables | |
| |
| |
Creating the Cross Join | |
| |
| |
Creating the Self-Join | |
| |
| |
Join Tables with Shared Column Names | |
| |
| |
Creating the Natural Join | |
| |
| |
Creating the Named Column Join | |
| |
| |
Use the Condition Join | |
| |
| |
Creating the Inner Join | |
| |
| |
Creating the Outer Join | |
| |
| |
Perform Union Operations | |
| |
| |
| |
Using Subqueries to Access and Modify Data | |
| |
| |
Create Subqueries That Return Multiple Rows | |
| |
| |
Using the IN Predicate | |
| |
| |
Using the EXISTS Predicate | |
| |
| |
Using Quantified Comparison Predicates | |
| |
| |
Create Subqueries That Return One Value | |
| |
| |
Work with Correlated Subqueries | |
| |
| |
Use Nested Subqueries | |
| |
| |
Use Subqueries to Modify Data | |
| |
| |
Using Subqueries to Insert Data | |
| |
| |
Using Subqueries to Update Data | |
| |
| |
Using Subqueries to Delete Data | |
| |
| |
| |
Advanced Data Access | |
| |
| |
| |
Creating SQL-Invoked Routines | |
| |
| |
Understand SQL-Invoked Routines | |
| |
| |
SQL-Invoked Procedures and Functions | |
| |
| |
Working with the Basic Syntax | |
| |
| |
Create SQL-Invoked Procedures | |
| |
| |
Invoking SQL-Invoked Procedures | |
| |
| |
Add Input Parameters to Your Procedures | |
| |
| |
Using Procedures to Modify Data | |
| |
| |
Add Local Variables to Your Procedures | |
| |
| |
Work with Control Statements | |
| |
| |
Create Compound Statements | |
| |
| |
Create Conditional Statements | |
| |
| |
Create Looping Statements | |
| |
| |
Add Output Parameters to Your Procedures | |
| |
| |
Create SQL-Invoked Functions | |
| |
| |
| |
Creating SQL Triggers | |
| |
| |
Understand SQL Triggers | |
| |
| |
Trigger Execution Context | |
| |
| |
Create SQL Triggers | |
| |
| |
Referencing Old and New Values | |
| |
| |
Dropping SQL Triggers | |
| |
| |
Create Insert Triggers | |
| |
| |
Create Update Triggers | |
| |
| |
Create Delete Triggers | |
| |
| |
| |
Using SQL Cursors | |
| |
| |
Understand SQL Cursors | |
| |
| |
Declaring and Opening SQL Cursors | |
| |
| |
Declare a Cursor | |
| |
| |
Working with Optional Syntax Elements | |
| |
| |
Creating a Cursor Declaration | |
| |
| |
Open and Close a Cursor | |
| |
| |
Retrieve Data from a Cursor | |
| |
| |
Use Positioned UPDATE and DELETE Statements | |
| |
| |
Using the Positioned UPDATE Statement | |
| |
| |
Using the Positioned DELETE Statement | |
| |
| |
| |
Managing SQL Transactions | |
| |
| |
Understand SQL Transactions | |
| |
| |
Set Transaction Properties | |
| |
| |
Specifying an Isolation Level | |
| |
| |
Specifying a Diagnostics Size | |
| |
| |
Creating a SET TRANSACTION Statement | |
| |
| |
Start a Transaction | |
| |
| |
Set Constraint Deferability | |
| |
| |
Create Savepoints in a Transaction | |
| |
| |
Releasing a Savepoint | |
| |
| |
Terminate a Transaction | |
| |
| |
Committing a Transaction | |
| |
| |
Rolling Back a Transaction | |
| |
| |
| |
Accessing SQL Data from Your Host Program | |
| |
| |
Invoke SQL Directly | |
| |
| |
Embed SQL Statements in Your Program | |
| |
| |
Creating an Embedded SQL Statement | |
| |
| |
Using Host Variables in Your SQL Statements | |
| |
| |
Retrieving SQL Data | |
| |
| |
Error Handling | |
| |
| |
Create SQL Client Modules | |
| |
| |
Defining SQL Client Modules | |
| |
| |
Use an SQL Call-Level Interface | |
| |
| |
Allocating Handles | |
| |
| |
Executing SQL Statements | |
| |
| |
Working with Host Variables | |
| |
| |
Retrieving SQL Data | |
| |
| |
| |
Working with XML Data | |
| |
| |
Learn the Basics of XML | |
| |
| |
Learn About SQL/XML | |
| |
| |
The XML Data Type | |
| |
| |
SQL/XML Functions | |
| |
| |
SQL/XML Mapping Rule | |
| |
| |
| |
Appendices | |
| |
| |
| |
Answers to Self Test | |
| |
| |
| |
SQL:2006 Keywords | |
| |
| |
SQL Reserved Keywords | |
| |
| |
SQL Nonreserved Keywords | |
| |
| |
| |
SQL Code Used in Try This Exercises | |
| |
| |
SQL Code by Try This Exercise | |
| |
| |
The INVENTORY Database | |
| |
| |
Index | |