🔥 $100K Hit! Where Will Bitcoin Go Next? Find Out Live!

Code has been added to clipboard!

SQL CREATE TABLE

Reading time 1 min
Published Aug 9, 2017
Updated Oct 9, 2019

TL;DR – The SQL CREATE TABLE command creates a new table in your database. Each table has a name and is organized into columns and rows. You can define the data held in the column by using the datatype parameter.

The SQL CREATE TABLE syntax

Example
CREATE TABLE mytable (
    column1 datatype,
    column2 datatype,
    column3 datatype,
   ....
);
DataCamp
Pros
  • Easy to use with a learn-by-doing approach
  • Offers quality content
  • Gamified in-browser coding experience
  • The price matches the quality
  • Suitable for learners ranging from beginner to advanced
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable
Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid Certificates of completion
edX
Pros
  • A wide range of learning programs
  • University-level courses
  • Easy to navigate
  • Verified certificates
  • Free learning track available
Main Features
  • University-level courses
  • Suitable for enterprises
  • Verified certificates of completion

Copying an existing table

Example
CREATE TABLE mynew_table_name AS
    SELECT column1, column2,...
    FROM myexisting_table_name
    WHERE ....;

An example of creating an SQL table

Example
CREATE TABLE Suppliers (
    SupplierID int,
    FirstName varchar(255),
    LastName varchar(255),
    City varchar(255),
    Country varchar(255) 
);

Note: you can fill the empty table with data later by using the INSERT INTO statement.

The result

ID First_Name Last_Name City Country