CREATE TABLE

SQL CREATE TABLE Keyword

The CREATE TABLE command is used to create a new table in the database. You define the table name and specify each column’s name and data type.

Tutorials dojo strip

SQL CREATE TABLE Syntax

CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    ...
)

SQL CREATE TABLE Example

This creates a new table named Mechanics with five columns.

CREATE TABLE Mechanics (
    MechanicID INT,
    LastName VARCHAR(255),
    FirstName VARCHAR(255),
    Specialty VARCHAR(255),
    ShopLocation VARCHAR(255)
)

SQL CREATE TABLE Using Another Table Syntax

You can also create a new table by copying selected columns and data from an existing table.

CREATE TABLE new_table AS
SELECT column1 column2
FROM existing_table

SQL CREATE TABLE Using Another Table Example

This creates a new table named PatientNames with only the first_name and last_name columns from the Patients table.

CREATE TABLE PatientNames AS
SELECT first_name last_name
FROM Patients

SQL CREATE TABLE Labs

Tutorials dojo strip
Scroll to Top