SQL CREATE TABLE statement

The SQL CREATE TABLE statement is used to create tables. To create a table using this statement, you must specify the following information:

  • the name of the new table after the keywords CREATE TABLE
  • the name and data type of the table columns separated by commas. You will also need to specify the size parameter that defines the maximum length of the column of the table.
  • some DMBSs require that you also specify the table location.

Here is the syntax:

CREATE TABLE table_name
(
columnname1 data_type(size),
columnname2 data_type(size),
columnname3 data_type(size),
columnname4 data_type(size),
);

Here is an example. The following SQL statement will create the Products table:

CREATE TABLE Products
(
product_id CHAR(15),
vendor_id CHAR(15),
product_name CHAR(254),
product_price DECIMAL(8,2),
);

Geek University 2022