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 a number of revisions - SQL-89, SQL-92, SQL:1999, SQL:2003, SQL:2008 and SQL:2011.
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 of SQL in order to communicate with the database engine, consider the sample table design below:
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,
PRIMARY KEY (name));
Insert a record into the table
INSERT INTO customer ('adam smith', 180, 75, '1975/03/25');
Update records in a table
UPDATE customer SET weight = 80 WHERE name = 'adam smith';
Delete records from the table
DELETE FROM customer WHERE name = 'adam smith';