Create Table Usage in SQL

Itacen Sabacok | Oct 2, 2021

CREATE TABLE statement is used to create a new table in a database.

1-- syntax
2-- datatype can be "integer,char,text,date..."
3CREATE TABLE table_name (
4    column1 datatype,
5    column2 datatype,
6    column3 datatype,
7   ....
8);
1-- example
2CREATE TABLE Course (
3    id int,
4    certid int,
5    coursename varchar(100),
6    courselink varchar(255)
7);

Here is the empty Course table

id certid coursename courselink

TIP

you can add data into your table with the following statement INSERT INTO


Create Table Using Another Table

1CREATE TABLE newTable AS
2SELECT column1, column2
3FROM existingTable
4WHERE column IS NOT NULL;