SQL or Structured Query Language is the lingua franca
for databases. SQL is used by programs or human users
to communicate with the database engine in order to
instruct the database engine to perform actions on the
data tables.
SQL was first standardized by the American National
Standards Institute (ANSI) and the International Organization
for Standardization (ISO) as ANSI/ISO SQL in 1986. There
has since been 3 revisions - SQL-89, SQL-92 and SQL-99.
Although there are many SQL reserved words, there are
only a few commands and keywords that are commonly used
- CREATE, ALTER, SELECT, INSERT, UPDATE, DELETE, FROM,
WHERE, OR, AND, ORDER, GROUP and BY.
To illustrate the use SQL in order to communicate with
the database engine, consider the sample table design
below:
customer
table
=============
name (primary key)
height
weight
dateofbirth
The following simple SQL commands are used to create
the table; insert records into the table; select records
from the table; update the data in the table; and delete
records from the table.
create the table
================
CREATE TABLE CUSTOMER( NAME VARCHAR(50)
NOT NULL, HEIGHT INTEGER,
WEIGHT INTEGER, DATEOFBIRTH VARCHAR(10),
PRIMARY KEY (NAME));
insert records into table
=========================
INSERT INTO CUSTOMER ('adam smith', 180, 75, '1975/03/25');
update records in table
=======================
UPDATE CUSTOMER SET WEIGHT = 80 WHERE NAME = 'adam
smith';
delete records from table
=========================
DELETE FROM CUSTOMER WHERE NAME = 'adam smith';