Monday, June 26, 2017

Basics of Create Table statement in MySQL

Here are basics of Create Table statement in MySQL to get started and have a hands on experience.

1. Create Table : 


CREATE TABLE MyFirstTable(
   column1  INT  NOT NULL,
   column2  VARCHAR (20) NOT NULL,
   column3  INT NOT NULL,
   column4  CHAR (25) ,
   PRIMARY KEY (column1)
);
Explanation:

MyFirstTable is the table name 
column1  is 1st column that accepts only integer values and cannot be null.
column2  is 2nd column that accepts only Varchar i.e. String values and cannot be null.
column3  is 3rd column that accepts only integer values and cannot be null.
column4  is 3rd column that accepts only character values upto maximum of 25.

column1  also acts as a primary key i.e unique row identifier. No two rows can ever have the same value in column1 .