2.10. CREATE

The create statement is used to create new tables in the database.

2.10.1. Syntax

create table tablename (
        column coltype options,
        column coltype options,
        ...
        primary key (colname)
)

Data types include (but are not limited to):

Table 2-8. Some data types

INTan integer number
FLOATa floating point number
CHAR(n)character data of exactly n characters
VARCHAR(n)character data of up to n characters (field grows/shrinks to fit)
BLOBBinary Large OBject
DATEA date in YYYY-MM-DD format
ENUMenumerated string value (eg "Male" or "Female")

Data types vary slightly between different database systems. The full range of MySQL data types is outlined in section 7.2 of the MySQL reference manual.

2.10.2. Examples

create table contactlist (
        id int not null auto_increment, 
        name varchar(30), 
        phone varchar(30), 
        primary key (id)
)