Structured Query Language (SQL) is a widely-used programming language for working with relational databases. The name of the language is generally pronounced as the three letters of its abbreviation About this sound ˈɛs kjuː ˈɛl or, in some people's usage, as About this sound ˈsiːkwəl.

This Wikibook provides a short description of SQL, its origins, basic concepts and components, and a lot of examples. The book follows the specifications of the SQL:2011 standard, which is developed by a common committee of ISO and IEC. Their publications are not freely available, but can be ordered online.[1] Or you may want to refer to a working draft, which you can download from Whitemarsh Information Systems Corporation.


Introduction

About the Book
Database Management Systems (DBMS)
Relational DBMS (rDBMS)
SQL: A Language for Working with rDBMS
SQL: The Standard ISO IEC 9075 and various Implementations
Language Elements
Learning by Doing


The Snippets Corner Take a snippet

SELECT code FROM examples WHERE topic = ...
Two Parallel Tracks: Standard and Classic

Standard Track

Classic Track


Foundation
Create a simple Table
Handle Data
Example Database Structure
Example Database Data

Basic Commands
SELECT Fundamentals









COMMIT and ROLLBACK
INSERT
UPDATE

DELETE

Daily Operations
SELECT

Join Operation
Grouping
IS NULL Predicate
Predefined Functions
Set Operations
Case Expression
Subquery

Views

INSERT
UPDATE
MERGE
DELETE
TRUNCATE



Advanced Topics
Managing Tables

CREATE TABLE
Data Types
Foreign Key
Alter Table
Drop Table
Temporary Table

Managing Indexes
Managing Rights (GRANT / REVOKE)

Advanced SELECT features

Pattern Matching (LIKE Predicate and much more)
IN, SOME/ANY, ALL, EXISTS
Advanced Grouping: Rollup / Cube
Window functions (Data Warehouses, OLAP)
With Clause (Common Table Expression CTE)
Recursions
NULLs and the Three Valued Logic

Transactions / Isolation Levels

Some Notes on typical SQL (non-trivial) Tasks

Retrieve Top N Rows per Group
Eliminate Duplicates



  Relational Databases





  Data Query Language










  Data Manipulation Language








  Data Definition Language





  Performance
  Data Control Language

  DB2 Return Codes

End of Parallel Tracks

Appendices

Warnings and Exceptions (SQLSTATE)
Glossary

References

  1. "ISO/IEC 9075-2:2011: Information technology -- Database languages -- SQL -- Part 2: Foundation (SQL/Foundation)".

See also



Please add {{alphabetical}} only to book title pages.