Académique Documents
Professionnel Documents
Culture Documents
Fabio Petrillo
Chargé de Cours This work is licensed under a Creative
Commons Attribution-NonCommercial-
ShareAlike 3.0 Unported License
The Structured Query Language (SQL)
● The SQL language is the most common query language, and may be
considered one of the major reasons for the commercial success of relational
databases. De facto standard for relational databases
● SQL language provides a higher-level declarative language interface, so
the user only specifies what the result is to be, leaving the actual
optimization and decisions on how to execute the query to the DBMS
● SQL is a comprehensive database language: It has statements for data
definitions, queries, and updates. Hence, it is both a DDL and a DML.
● SQL is flexible, expressive and powerful
● Because the SQL specification is very large, we give a description of the most
important features.
● You must master SQL!
SQL History
● IBM SEQUEL language developed as part of System R project at the IBM
San Jose Research Laboratory
● Renamed Structured Query Language (SQL)
● ANSI and ISO standard SQL:
○ SQL-86,SQL-89,SQL-92,SQL:1999,
○ SQL:2003
● Commercial systems offer most, if not all, SQL-92 features, plus varying
feature sets from later standards and special proprietary features.
The Structured Query Language (SQL)
● SQL is a nonprocedural and declarative language; you specify what
information you require, rather than how to get it.
● SQL does not require you to specify the access methods to the data.
● SQL is essentially free-format, which means that parts of statements do not
have to be typed at particular locations on the screen.
● The command structure consists of standard English words such as CREATE
TABLE, INSERT, SELECT
● Most components of an SQL statement are case-insensitive
● Example of SQL query
Data Definition Language (DDL)
The SQL data-definition language (DDL) allows the specification of information
about relations, including:
● The Database
● The schema for each relation.
● The domain of values associated with each attribute.
● Integrity constraints
● The set of indices to be maintained for each relations.
● Security and authorization information for each relation.
● The physical storage structure of each relation on disk.
SQL Data Definition Commands
Creating and Dropping Database Schema
● Create schema
● Dropping schema
Examples:
UPDATE TableName
SET columnName1 = dataValue1 [, columnName2 = dataValue2 . . .]
[WHERE searchCondition]
Example
Example
Example: