Monday, 18 July 2016

Important Queries in Mysql



1. How to change datatype of column

ALTER TABLE `tablename`.`period`
CHANGE COLUMN `PERIOD_NO` `PERIOD_NO` INT(20) NULL DEFAULT NULL ;


2.How to add  column name

alter table productinfo
add column DEMO_CALL_NO2 VARCHAR(45) AFTER DEMO_CALL_NO;

3.How to rename existing table name

rename table userinfoTable to productinfoTable

4.How to rename existing column name

ALTER TABLE productinfo
CHANGE COLUMN DEMO_CALL_NO DEMO_CALL_NO1 VARCHAR(45)

5.How to add primary key with autoincrement in existing table

alter table productinfo

add column PRD_ID int not null auto_increment primary key first


6.How to drop existing column from table

alter table productinfo

drop column PRD_ID

7. How to default value to existing column

ALTER TABLE mattress_multiple
MODIFY COLUMN FOAM_STATUS VARCHAR(45) NOT NULL DEFAULT 0



Coming Soon...............................

No comments:

Post a Comment