English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Usage and examples of the SQL CREATE TABLE keyword

SQL Keyword Reference

CREATE TABLE (Create table)

The CREATE TABLE command creates a new table in the database.

The following SQL creates a table named "Persons", which contains five columns: PersonID, LastName, FirstName, Address, and City:

CREATE TABLE Persons
(
   
PersonID int,
   
LastName varchar(255),
   
FirstName varchar(255),
   
Address varchar(255),
   
City varchar(255) 
);

Create a table using another table

The following SQL creates a new table named "TestTables" (the table is a copy of two columns from the "Customers" table): 

  CREATE TABLE TestTable AS
SELECT customername, contactname
FROM 
  customers;

SQL Keyword Reference