Once database is created, we can start to create the required tables that would contain all the informations.
In SQL, CREATE TABLE statement helps you to create a new table in database.
To create a table, we need to:
name the table appropriately
define the coloumns that the table will have,
define the datatype of each column
Syntax of CREATE TABLE
CREATE TABLE table_name (
Example on CREATE TABLE
Suppose we want to have a table for our site tutorials in hand, named tih_Courses having Course_ID, Course_Name, Professor andMode_of_Training offered.
We will write create statement as shown below:
CREATE TABLE tih_Courses (
Course_ID INT NOT NULL,
An empty table with the name tih_Courses will get created as shown below:
Data each coloumn holds
Data types such as int, varchar, etc defines the type of value that the particular coloumn can hold.
Course_ID → INT represents that couse id should only allow integer value.
Course_Name → VARCHAR indicates that it holds character value. 30 indicates the maximum length allowed.
Professor → VARCHAR indicates that it holds character value. 25 indicates the maximum length allowed.
Mode_of_Training → VARCHAR indicates that it holds character value. 20 indicates the maximum length allowed.
What you can do with this table?
You can insert data in this table using sql INSERT statement.
You can update the table data as per requirement using sql UPDATE statement.
You can rename the table using sql RENAME.
You can delete the table using sql DELETE statement
You can drop the table using sql DROP statement
You can apply constraints as well for particular coloumn such as NOT NULL, make it primary key