The CREATE Table statement is creates a database table with the given name. A table creation statement requires three parameters. The name of table specify table name in database. The column parameters specify the names of the columns of the table. The datatype parameter specifies the type of data to be store (e.g. varchar, integer, date, etc.).
Tip: In order to get compelet details of the available data types, go to our MySQL Data Types section.
In the above example, The pk column is of type int NOT NULL and will hold an integer. The NOT NULL is a field attribute and it is used to make sure field should not be NULL.
The firstName, lastName and address fields are of type varchar and will hold characters with specified length. The NULL is a field attribute and it is used to allow NULL value to be stored.
The field attribute AUTO_INCREMENT specifies MySQL to go ahead and add the next available number to the pk field. PRIMARY KEY is used to define a column as primary key.
You can use MySQL Command Line Client to create table. It will look like this:
You can use MySQL Command Line Client to show table. It will look like this:
You can use MySQL Command Line Client to show table structure. It will look like this: