Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

CREATE TABLE

CREATE TABLE

The CREATE TABLE command establishes a fresh table within the database.

In the provided SQL, it generates a table named “Persons” with five columns: PersonID, LastName, FirstName, Address, and City.

Example

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

CREATE TABLE Using Another Table

This SQL statement creates a new table named “TestTables,” which duplicates two columns from the “Customers” table.

Example

CREATE TABLE TestTable AS
SELECT customername, contactname
FROM customers;