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.
This allows you to extract, change, update, and delete data in tables of a database.
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 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 |
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;
You can create, change, and delete tables, or define or delete keys.