CPT 106
Franklin College
Fall 2003
Erich Prisner,

...

SQL

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, but ANSI-SQL 

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

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;


Erich Prisner, 11/22/2003