SQL – How To Create A Table?


SQL – How To Create A Table?

Table Of Contents:

  1. Syntax Of Creating A Table.
  2. Examples Of Creating A Table.

(1) Syntax Of Creating A Table

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

(2) Examples Of Creating A Table

Example-1: Creating A New Table

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

Example-2: Create Table Using Another Table

CREATE TABLE TestTable AS
SELECT customername, contactname
FROM customers;

Leave a Reply

Your email address will not be published. Required fields are marked *