SQL CREATE TABLE Statement
SQL CREATE TABLE Statement
w3schools.com
Trendsetters Feed
not Jony Ive Wash your hands as though you’ve been touching an Android
@JonyIveParody • 3d View device or Windows PC all day. #coronavirus https://t.co/ei32BvL...
image
Syntax
The column parameters specify the names of the columns of the table.
The datatype parameter specifies the type of data the column can hold (e.g. varchar,
integer, date, etc.).
Tip: For an overview of the available data types, go to our complete Data Types
Reference.
https://www.w3schools.com/sql/sql_create_table.asp 1/9
3/21/2020 SQL CREATE TABLE Statement
Example
CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
Try it Yourself »
The LastName, FirstName, Address, and City columns are of type varchar and will hold
characters, and the maximum length for these fields is 255 characters.
Tip: The empty "Persons" table can now be filled with data with the SQL INSERT INTO
statement.
https://www.w3schools.com/sql/sql_create_table.asp 2/9
3/21/2020 SQL CREATE TABLE Statement
The new table gets the same column definitions. All columns or specific columns can be
selected.
If you create a new table using an existing table, the new table will be filled with the
existing values from the old table.
Syntax
The following SQL creates a new table called "TestTables" (which is a copy of the
"Customers" table):
Example
Try it Yourself »
Exercise:
Write the correct SQL statement to create a new table called Persons .
https://www.w3schools.com/sql/sql_create_table.asp 3/9
3/21/2020 SQL CREATE TABLE Statement
Submit Answer »
❮ Previous Next ❯
https://www.w3schools.com/sql/sql_create_table.asp 4/9
3/21/2020 SQL CREATE TABLE Statement
Bi-
directional
Email
Sync
Nylas APIs
Power your
application with bi-
directional sync
and send from any
inbox in the world.
LEARN MORE
COLOR PICKER
HOW TO
Tabs
Dropdowns
Accordions
Side Navigation
Top Navigation
https://www.w3schools.com/sql/sql_create_table.asp 5/9
3/21/2020 SQL CREATE TABLE Statement
Modal Boxes
Progress Bars
Parallax
Login Form
HTML Includes
Google Maps
Range Sliders
Tooltips
Slideshow
Filter List
Sort List
SHARE
CERTIFICATES
HTML
CSS
JavaScript
SQL
Python
PHP
jQuery
Bootstrap
XML
Read More »
https://www.w3schools.com/sql/sql_create_table.asp 6/9
3/21/2020 SQL CREATE TABLE Statement
Spin up
CockroachDB
on AWS
CockroachDB
Database
Management on
AWS - Try it Free
Bi-directional Email S
https://www.w3schools.com/sql/sql_create_table.asp 7/9
3/21/2020 SQL CREATE TABLE Statement
___
Sponsored
REPORT ERROR
PRINT PAGE
FORUM
ABOUT
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
PHP Tutorial
jQuery Tutorial
Java Tutorial
C++ Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
https://www.w3schools.com/sql/sql_create_table.asp 8/9
3/21/2020 SQL CREATE TABLE Statement
HTML Colors
jQuery Reference
Java Reference
Angular Reference
Top Examples
HTML Examples
CSS Examples
JavaScript Examples
How To Examples
SQL Examples
Python Examples
W3.CSS Examples
Bootstrap Examples
PHP Examples
jQuery Examples
Java Examples
XML Examples
Web Certificates
HTML Certificate
CSS Certificate
JavaScript Certificate
SQL Certificate
Python Certificate
jQuery Certificate
PHP Certificate
Bootstrap Certificate
XML Certificate
Get Certified »
W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading
and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our
terms of use, cookie and privacy policy. Copyright 1999-2020 by Refsnes Data. All Rights Reserved.
Powered by W3.CSS.
https://www.w3schools.com/sql/sql_create_table.asp 9/9