Create, alter, drop

       In this category of SQL, we affect the structure of the database, not the content. The first example shows a create sentence, where you typically make a new table. Here's a simple example:

CREATE TABLE player (
    p_name   VARCHAR(50) NOT NULL PRIMARY KEY,
    password VARCHAR(50) NOT NULL
)
       Create the table "player", with a column called "p_name" (50 characters at most, and there has to be something, and this is the primary key of the table), and a column called "password" (50 characters at most, and there has to be something).
       Sometimes there's the need to change in the already existing tables - e.g. create a new column. Below there's a simple example.
ALTER TABLE player
    ADD gender VARCHAR(10)
       Change the table "player", by adding a new column, called "gender" (10 characters at most).
       Finally there can be the need to delete an entire table. Here's an example.
DROP TABLE player
       Delete the table "player".

Concept last updated: 06/05 2004.

Relations

is a kind of

Other sources

Computer Create, alter, drop CSS

Libellus