SQL – Create Table

Spread the love

SQL – Create Table – needs to define data types for columns and storing the data.

Syntax  –

Create Table TableName
( column1 datatype , column2 datatype ) ;

Create Table Customer_ContactDetails
( Cust_ID int ,
First_Name Varchar(15) ,
Middle_Name Varchar(15) ,
Last_Name Varchar(15) ,
Contact_No Char(10) ,
Cust_Address Varchar(Max)


Select * from Customer_ContactDetails

IDFirst_Name Last_NameContact_NoCust_Address

Note – Make a habit to use Underscore instead of Space in fields name ( as used in above for First_Name)

  • For better table designing , a developer needs to consider/predict the table size and growth , measure dependent table , primary key and foreign key relationship with other tables.
  • Select a proper data type for the field , which helps to manage/maintain the large tables in production environment.
  • Like – Generally  phone numbers  have 10 characters  , so define 10 digit numeric/char(10) etc.