Data definition language or DDL is a language which is used to create and destroy tables (also known as dropping tables). Using this language you can define the structure, the fields, primary keys and even indices.

Most of you will of used a GUI to create your tables in programs such as access. However access’s front end will use the DDL to create the table. SQL is the most common so let’s look at how to create the table below in SQL.

 

Personal ( ID, Forename, Surname)

 

Create TABLE personal {

ID integer PRIMARY KEY,

Forename varchar(30),

Surname varchar(30)

};

Create TABLE is the command to create a table. The next thing it expects is the name of the table. Then you tell it all of the fields inside {} brackets. Notice the semi-colon `;` at the end of the statement. The above is treated as a single command. In SQL you are supposed to finish all commands with a semi-colon. This keeps in line with many popular programming languages such as Java, C++ and javascript.

The columns are separated with commas. First of all you put the name of the column, followed by its type and then followed by any special instructions. In the above example we have use the special instruction of PRIMARY KEY. This sets the field ID to be the primary key. The integer data type should be familiar however the varchar will not. Varchar is text. The number in brackets after defines the size of the varchar. As such we are allowing 30 characters for both forename and surname.

In order to delete a table you can use the following command.

DROP TABLE personal;