Jump to content

Structured Query Language

100% developed
From Wikibooks, open books for an open world
(Redirected from SQL)


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 many examples. The book follows the specifications of the SQL:2011 standard 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 that 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 = ...

Foundation

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

Data Query Language

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

Data Manipulation Language

INSERT
INSERT, using Subqueries
UPDATE
UPDATE, using Subqueries
DELETE
DELETE, using Subqueries
MERGE
TRUNCATE
COMMIT and ROLLBACK

Data Definition Language

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

Data Control Language

Managing Rights (GRANT / REVOKE)

Advanced Topics

Additional 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

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