Data Definition Language, CREATE TABLE
This starts Data Definition Language (DDL) commands. See Table Creation and SQL is DML, DDL, & DCL.
While a DataBase Administrator (DBA) will normally perform the DDL and DCL functions, you need to know how they work so that you can convey your needs to the DBA.As previously described, a database table is a two-dimensional array of columns (or attributes) and rows (or records).
You use a CREATE TABLE comand to specify the name and data type of each column.
Format:
CREATE TABLE table_name (
column_name1 data_type1 [col_constraint1],
column_name2 data_type2 [col_constraint2],
...
[CONSTRAINT constraint_name1 table_constraint1,]
[CONSTRAINT constraint_name2 table_constraint2,]
...
);
Once the table is created, you can start loading it with data. This is done with the INSERT statement described earlier. ALTER TABLE changes the attributes of the table and DROP TABLE will remove the table definition.
As you design your tables, you will need to go through table normalization which is a way of structuring your tables so that updates do not introduce abnormalities.
The column_name must be a valid identifier according to the rules of each RDBMS.
The specific data_type associated with the column name may contain a length according to the RDBMS.
The constraint specifies constraints on the data such as NOT NULL and DEFAULT.