| Acknowledgments | p. xi |
| Introduction | p. xi |
| Relational Databases and SQL | |
| Introduction to Relational Databases and SQL | p. 3 |
| Understand Relational Databases | p. 4 |
| The Relational Model | p. 5 |
| Learn About SQL | p. 15 |
| The SQL Evolution | p. 15 |
| Types of SQL Statements | p. 18 |
| Types of Execution | p. 19 |
| SQL Standard versus Product Implementations | p. 21 |
| Working with the SQL Environment | p. 29 |
| Understand the SQL Environment | p. 30 |
| Understand SQL Catalogs | p. 32 |
| Schemas | p. 34 |
| Schema Objects | p. 35 |
| Then What Is a Database? | p. 37 |
| Name Objects in an SQL Environment | p. 40 |
| Qualified Names | p. 41 |
| Create a Schema | p. 42 |
| Create a Database | p. 44 |
| Creating and Altering Tables | p. 49 |
| Create SQL Tables | p. 50 |
| Specify Column Data Types | p. 54 |
| String Data Types | p. 55 |
| Numeric Data Types | p. 57 |
| Datetime Data Types | p. 58 |
| Interval Data Type | p. 60 |
| Boolean Data Type | p. 61 |
| Using SQL Data Types | p. 62 |
| Create User-Defined Types | p. 63 |
| Specify Column Default Values | p. 64 |
| Delete SQL Tables | p. 69 |
| Enforcing Data Integrity | p. 73 |
| Understand Integrity Constraints | p. 74 |
| Use NOT NULL Constraints | p. 76 |
| Add UNIQUE Constraints | p. 77 |
| Add PRIMARY KEY Constraints | p. 79 |
| Add FOREIGN KEY Constraints | p. 83 |
| The MATCH Clause | p. 88 |
| The [left angle bracket]referential triggered action[right angle bracket] Clause | p. 89 |
| Define CHECK Constraints | p. 95 |
| Defining Assertions | p. 97 |
| Creating Domains and Domain Constraints | p. 98 |
| Creating SQL Views | p. 103 |
| Add Views to the Database | p. 104 |
| Defining SQL Views | p. 108 |
| Create Updateable Views | p. 114 |
| Using the WITH CHECK OPTION Clause | p. 116 |
| Drop Views from the Database | p. 117 |
| Managing Database Security | p. 123 |
| Understand the SQL Security Model | p. 124 |
| SQL Sessions | p. 126 |
| Accessing Database Objects | p. 128 |
| Create and Delete Roles | p. 130 |
| Grant and Revoke Privileges | p. 131 |
| Revoking Privileges | p. 135 |
| Grant and Revoke Roles | p. 137 |
| Revoking Roles | p. 138 |
| Data Access and Modification | |
| Querying SQL Data | p. 145 |
| Use a SELECT Statement to Retrieve Data | p. 146 |
| The SELECT Clause and FROM Clause | p. 147 |
| Use the WHERE Clause to Define Search Conditions | p. 152 |
| Defining the WHERE Clause | p. 156 |
| Use the GROUP BY Clause to Group Query Results | p. 159 |
| Use the HAVING Clause to Specify Group Search Conditions | p. 164 |
| Use the ORDER BY Clause to Sort Query Results | p. 166 |
| Modifying SQL Data | p. 175 |
| Insert SQL Data | p. 176 |
| Inserting Values from a SELECT Statement | p. 180 |
| Update SQL Data | p. 182 |
| Updating Values from a SELECT Statement | p. 185 |
| Delete SQL Data | p. 186 |
| Using Predicates | p. 193 |
| Compare SQL Data | p. 194 |
| Using the BETWEEN Predicate | p. 199 |
| Return Null Values | p. 200 |
| Return Similar Values | p. 203 |
| Reference Additional Sources of Data | p. 209 |
| Using the IN Predicate | p. 209 |
| Using the EXISTS Predicate | p. 213 |
| Quantify Comparison Predicates | p. 216 |
| Using the SOME and ANY Predicates | p. 216 |
| Using the ALL Predicate | p. 218 |
| Working with Functions and Value Expressions | p. 225 |
| Use Set Functions | p. 226 |
| Using the COUNT Function | p. 227 |
| Using the MAX and MIN Functions | p. 229 |
| Using the SUM Function | p. 231 |
| Using the AVG Function | p. 232 |
| Use Value Functions | p. 232 |
| Working with String Value Functions | p. 233 |
| Working with Datetime Value Functions | p. 236 |
| Use Value Expressions | p. 238 |
| Working with Numeric Value Expressions | p. 238 |
| Using the CASE Value Expression | p. 241 |
| Using the CAST Value Expression | p. 244 |
| Use Special Values | p. 245 |
| Accessing Multiple Tables | p. 253 |
| Perform Basic Join Operations | p. 254 |
| Using Correlation Names | p. 257 |
| Creating Joins with More than Two Tables | p. 258 |
| Creating the Cross Join | p. 259 |
| Creating the Self-Join | p. 260 |
| Join Tables with Shared Column Names | p. 261 |
| Creating the Natural Join | p. 262 |
| Creating the Named Column Join | p. 263 |
| Use the Condition Join | p. 263 |
| Creating the Inner Join | p. 264 |
| Creating the Outer Join | p. 266 |
| Perform Union Operations | p. 269 |
| Using Subqueries to Access and Modify Data | p. 277 |
| Create Subqueries That Return Multiple Rows | p. 278 |
| Using the IN Predicate | p. 279 |
| Using the EXISTS Predicate | p. 281 |
| Using Quantified Comparison Predicates | p. 282 |
| Create Subqueries That Return One Value | p. 283 |
| Work with Correlated Subqueries | p. 284 |
| Use Nested Subqueries | p. 286 |
| Use Subqueries to Modify Data | p. 288 |
| Using Subqueries to Insert Data | p. 288 |
| Using Subqueries to Update Data | p. 290 |
| Using Subqueries to Delete Data | p. 291 |
| Advanced Data Access | |
| Creating SQL-Invoked Routines | p. 299 |
| Understand SQL-Invoked Routines | p. 300 |
| SQL-Invoked Procedures and Functions | p. 301 |
| Working with the Basic Syntax | p. 301 |
| Create SQL-Invoked Procedures | p. 303 |
| Invoking SQL-Invoked Procedures | p. 305 |
| Add Input Parameters to Your Procedures | p. 306 |
| Using Procedures to Modify Data | p. 309 |
| Add Local Variables to Your Procedures | p. 311 |
| Work with Control Statements | p. 313 |
| Create Compound Statements | p. 313 |
| Create Conditional Statements | p. 314 |
| Create Looping Statements | p. 316 |
| Add Output Parameters to Your Procedures | p. 320 |
| Create SQL-Invoked Functions | p. 321 |
| Creating SQL Triggers | p. 329 |
| Understand SQL Triggers | p. 330 |
| Trigger Execution Context | p. 331 |
| Create SQL Triggers | p. 333 |
| Referencing Old and New Values | p. 334 |
| Dropping SQL Triggers | p. 335 |
| Create Insert Triggers | p. 336 |
| Create Update Triggers | p. 338 |
| Create Delete Triggers | p. 343 |
| Using SQL Cursors | p. 351 |
| Understand SQL Cursors | p. 352 |
| Declaring and Opening SQL Cursors | p. 353 |
| Declare a Cursor | p. 355 |
| Working with Optional Syntax Elements | p. 356 |
| Creating a Cursor Declaration | p. 360 |
| Open and Close a Cursor | p. 363 |
| Retrieve Data from a Cursor | p. 363 |
| Use Positioned UPDATE and DELETE Statements | p. 368 |
| Using the Positioned UPDATE Statement | p. 368 |
| Using the Positioned DELETE Statement | p. 370 |
| Managing SQL Transactions | p. 377 |
| Understand SQL Transactions | p. 378 |
| Set Transaction Properties | p. 381 |
| Specifying an Isolation Level | p. 382 |
| Specifying a Diagnostics Size | p. 387 |
| Creating a SET TRANSACTION Statement | p. 388 |
| Start a Transaction | p. 389 |
| Set Constraint Deferability | p. 390 |
| Create Savepoints in a Transaction | p. 392 |
| Releasing a Savepoint | p. 394 |
| Terminate a Transaction | p. 395 |
| Committing a Transaction | p. 395 |
| Rolling Back a Transaction | p. 396 |
| Accessing SQL Data from Your Host Program | p. 403 |
| Invoke SQL Directly | p. 404 |
| Embed SQL Statements in Your Program | p. 406 |
| Creating an Embedded SQL Statement | p. 407 |
| Using Host Variables in Your SQL Statements | p. 408 |
| Retrieving SQL Data | p. 411 |
| Error Handling | p. 413 |
| Create SQL Client Modules | p. 417 |
| Defining SQL Client Modules | p. 418 |
| Use an SQL Call-Level Interface | p. 419 |
| Allocating Handles | p. 421 |
| Executing SQL Statements | p. 423 |
| Working with Host Variables | p. 424 |
| Retrieving SQL Data | p. 426 |
| Working with XML Data | p. 433 |
| Learn the Basics of XML | p. 434 |
| Learn About SQL/XML | p. 437 |
| The XML Data Type | p. 437 |
| SQL/XML Functions | p. 439 |
| SQL/XML Mapping Rule | p. 441 |
| Appendices | |
| Answers to Self Test | p. 449 |
| SQL:2006 Keywords | p. 491 |
| SQL Reserved Keywords | p. 492 |
| SQL Nonreserved Keywords | p. 494 |
| SQL Code Used in Try This Exercises | p. 497 |
| SQL Code by Try This Exercise | p. 498 |
| The INVENTORY Database | p. 514 |
| Index | p. 519 |
| Table of Contents provided by Ingram. All Rights Reserved. |