SQL CREATE TABLE Statement


The CREATE TABLE statement is used to create a new table in a database.

The figure shows the simplified syntax of CREATE TABLE where
CREATE TABLE table-name (
  column-name-1 type [NOT NULL | UNIQUE] [, column-name-2 ... ]
  [  AS SELECT ... FROM ... [ WHERE ... ] ]
  [, UNIQUE ( list-of-column-names ) [, UNIQUE ... ] ]
  [, PRIMARY KEY ( list-of-column-names ) ]
  [, FOREIGN KEY ( list-of-column-names )
      REFERENCES  table-name-2 [ ( list-of-column-names ) ]
  [, FOREIGN KEY ... ] ]
  [, CHECK ( condition ) [, CHECK ... ] ] )


Demonstration
Below is an SQL test area from W3Schools, which uses the well-known Northwind sample database. The tables here are for read only because of the problem of embedding the scripts. For a fully working example, check this by using Chrome.

SQL Statement:

Edit the SQL statement and click     to see the result, or  

Result:
The Database includes:
The Database includes:

TablenameRecord
Customers91
Categories8
Employees10
OrderDetails518
Orders196
Products77
Shippers3
Suppliers29