A Gentle Introduction to

SQL

CREATE and DROP

How to create tables, indexes, views and other things. How to get rid of them.


Composite primary key, foreign key
Composite primary key
the primary key is made up of more than one field
Foreign key
one (or more) field from this table relates to the primary key of another table
mysql variations:
  • We must explicitly specify that the components of the key are not NULL.
  • The foreign key statements don't do anything - referential integrity is not enforced.
.
Possible error messages:
Error 1171 All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead

access
db2
mysql
oracle
postgres
sqlserver