SQL ALTER TABLE Statement

SHOW Table:

select * from employeeinfo;

name age address salary
Komal 25 Mumbai 25000
Ramesh 35 Delhi 25000
Kaushik 31 Indore 25000
Hardik 22 Hyderabad 25000
Glory 28 Kanpur 25000
Akshaya 29 Delhi 25000

ALTER Table:

ALTER Table employeeinfo DROP Column salary;

select * from employeeinfo;

name age address
Komal 25 Mumbai
Ramesh 35 Delhi
Kaushik 31 Indore
Hardik 22 Hyderabad
Glory 28 Kanpur
Akshaya 29 Delhi

ALTER TABLE employeeinfo ADD dob date;

select * from employeeinfo;

name age address dob
Komal 25 Mumbai NULL
Ramesh 35 Delhi NULL
Kaushik 31 Indore NULL
Hardik 22 Hyderabad NULL
Glory 28 Kanpur NULL
Akshaya 29 Delhi NULL

UPDATE employeeinfo SET dob=’1985/01/28′ where name=’Akshaya’;

select * from employeeinfo;

name age address dob
Komal 25 Mumbai 1997-10-19
Ramesh 35 Delhi 1995-08-29
Kaushik 31 Indore 1991-05-05
Hardik 22 Hyderabad 1998-01-25
Glory 28 Kanpur 1990-12-15
Akshaya 29 Delhi 1985-01-28

Leave a Reply

Your email address will not be published. Required fields are marked *