S Q L  

Structured Query Language
CPT 106 · Franklin College · Erich Prisner · 2002-2006

Structured Query Language is the language in which to talk to databases to make them retrieve or update data. It is contained in most relational database system programs, as Access, Oracle, Visual FoxPro, There are several dialects.

SQL commands are written in rows, with key words capitalized, and end with a semicolon.

DML (SQL Data Manipulation Language)

This allows you to extract, change, update, and delete data in tables of a database.

Select

SELECT *
FROM
tablename;
displays a whole table.
SELECT column1, column3
FROM
tablename;
outputs the corresponding columns of the table.
SELECT column1
FROM
tablename
WHERE
condition;
outputs the corresponding columns of the table obeying the condition.

The first variant displays certain columns. The second one only certain columns and certain rows. The WHERE-condition could be something like

Try the syntax on this interactive page.

Insert and Update and Delete

INSERT into tablename 
(column1,column3)
VALUES (
value1, value3);
creates a new record with the corresponding values in the columns mentioned. Remember again to enclose all strings into single quotation marks.
UPDATE tablename
SET (
column1=value1, column3=value3)
WHERE
condition;
condition could be something like first = 'Erich" and last = 'Prisner'
DELETE from tablename
WHERE
condition;
deletes all records obeying the condition

Others

You can also create tables with SQL, like

CREATE table tablename
(
column1 varchar(10), column2 varchar(20), age number(3));

or delete them by DROP table tablename;

DDL (SQL Data Definition Language)

You can create, change, and delete tables, or define or delete keys.


Erich Prisner, 11/22/2003