SQL Getting Started

Table of Contents

Welcome

Related Documentation for This Book
Highlighting Conventions

Chapter 1. Relational Databases and SQL

Chapter 2. Organizing Data

Tables
Views
Schemas
Data Types

Chapter 3. Creating Tables and Views

Creating Tables
Inserting Data
Changing Data
Deleting Data
Creating Views
Using Views to Manipulate Data

Chapter 4. Using SQL Statements to Access Data

Connecting to a Database
Investigating Errors
Selecting Columns
Selecting Rows
Sorting Rows
Removing Duplicate Rows
Order of Operations
Using Expressions to Calculate Values
Naming Expressions
Selecting Data from More Than One Table
Using a Subquery
Using Functions
Column Functions
Scalar Functions
Table Functions
Grouping
Using a WHERE Clause with a GROUP BY Clause
Using the HAVING Clause After the GROUP BY Clause

Chapter 5. Expressions and Subqueries

Scalar Fullselects
Casting Data Types
Case Expressions
Table Expressions
Nested Table Expressions
Common Table Expressions
Correlation Names
Correlated Subqueries
Implementing a Correlated Subquery

Chapter 6. Using Operators and Predicates in Queries

Combining Queries by Set Operators
UNION Operator
EXCEPT Operator
INTERSECT operator
Predicates
Using the IN Predicate
Using the BETWEEN Predicate
Using the LIKE Predicate
Using the EXISTS Predicate
Quantified Predicates

Chapter 7. Advanced SQL

Enforcing Business Rules with Constraints and Triggers
Keys
Unique Constraints
Referential Integrity Constraints
Table Check Constraints
Triggers
Joins
Complex Queries
ROLLUP and CUBE Queries
Recursive Queries
OLAP Functions

Chapter 8. Customizing and Enhancing Data Manipulation

User-Defined Types
User-Defined Functions
Large Objects (LOBs)
Manipulating Large Objects (LOBs)
Special Registers
Introduction to Catalog Views
Selecting Rows from System Catalogs

Appendix A. Sample Database Tables

The Sample Database
To Create the Sample Database
To Erase the Sample Database
CL_SCHED Table
DEPARTMENT Table
EMPLOYEE Table
EMP_ACT Table
EMP_PHOTO Table
EMP_RESUME Table
IN_TRAY Table
ORG Table
PROJECT Table
SALES Table
STAFF Table
STAFFG Table
Sample Files with BLOB and CLOB Data Type
Quintana Photo
Quintana Resume
Nicholls Photo
Nicholls Resume
Adamson Photo
Adamson Resume
Walker Photo
Walker Resume

Appendix B. Using the DB2 Library

DB2 PDF Files and Printed Books
DB2 Information
Printing the PDF Books
Ordering the Printed Books
DB2 Online Documentation
Accessing Online Help
Viewing Information Online
Using DB2 Wizards
Setting Up a Document Server
Searching Information Online

Appendix C. Notices

Trademarks

Index

Contacting IBM

Product Information