How to create a table in SQL ?

SQL

The command to create a table in sql is extremely simple:

 CREATE TABLE table_name (
	column1 datatype,
	column2 datatype,
	column3 datatype,
   ....
);
We will start off by giving the keywords, CREATE TABLE, then we will give the name of the table. After that in braces, we will list out all the columns along with their datatypes. For example, if we want to create a simple employee table:

CREATE TABLE employee (
	name varchar(25),
	age int,
	gender varchar(25),
   ....
);
       

Advertisements

ads