Introduction to SQL

Basics

Release 1 of the SQL specs is 1986. Subsequent releases are SLQ/92 and SQL/99.

Relational databases are built on tables linked by unique primary and foreign keys.

SQL commands are grouped according to their usage:

_TBL is traditionally used as suffix for tables, and _INX for indexes.

A primary key is a unique record ID.

A schema is a collection of objects associated with a users, eg. user1.employees_tbl.

To create a table in a database: CREATE TABLE EMPLOYEES_TBL (ID_EMP CHAR(9) NOT NULL, NAME VARCHAR2(40) NOT NULL);

"The relational model is thus named, not because you can relate tables to one another (a popular misconception), but as a reference to the relationships between the columns in a table. These are the relationships that give the model its name; in other words, relational means that if several values belong to the same row in a table, they are related. The way columns are related to each other defines a relation, and a relation is a table (more exactly, a table represents one relation)." The Art of SQL By Stéphane Faroult, Peter Robson

Resources