< Sql Tutorial

Sql Table Create

← Previous Next →


 SQL Table

Table is a collection of data organized in terms of rows and column. Table is the simple form of data storage. A table is also considered as a convenient representation of relations. Let's see an example of an employee table:

EMP_NAME ADDRESS SALARY
ALOK TIWARI LUCKNOW 15000
RAMAN JAISWAL ALLAHABAD 18000
SHREYA SRIVASTAVA GHAZIABAD 20000

SQL CREATE TABLE

SQL CREATE TABLE statement is used to create table in a database. If you want to create a table, you should name the table and define its column and each column's data type. Let's see the simple syntax to create the table.

 create table "tablename"
("column1" "data type",
"column2" "data type",
"column3" "data type",...
"columnN" "data type");


The data type of the columns may vary from one database to another. For example, NUMBER is supported in Oracle database for integer value whereas INT is supported in MySQL.

Example in MySQL

Let's see the command to create a table in MySQL database.

 CREATE TABLE Employee
(EmployeeID int,
FirstName varchar(255),
LastName varchar(255),
Email varchar(255),
AddressLine varchar(255),
City varchar(255));


Example in Oracle

Let's see the command to create a table in Oracle database.

 CREATE TABLE Employee
(EmployeeID number(10),
FirstName varchar2(255),
LastName varchar2(255),
Email varchar2(255),
AddressLine varchar2(255),
City varchar2(255));
 
← Previous Next →