SQL Create Table


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

To create a table, you should name the table and define its column and each column's data type.

Syntax

CREATE TABLE table_name 
(
column_name1 DATATYPE, 
column_name2 DATATYPE, 
... column_nameN DATATYPE
)
  • table_name - is the name of the table.
  • column_name1, column_name2.... - is the name of the columns
  • datatype - is the datatype for the column like char, date, number etc.

CREATE TABLE is the keyword telling the database system what you want to do. In this case, you want to create a new table. The unique name or identifier for the table follows the CREATE TABLE statement.

Example

CREATE TABLE Persons
(
personID INT [10],
lastName VARCHAR(255),
firstName VARCHAR(255),
address VARCHAR(255),
city VARCHAR(255)
)

Share this article on