Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add new MySQL table columns and creating indexes

Tags:

I have this existing query to create an additional MySQL column to an existing table.:

$wpdb->query("ALTER TABLE mytable ADD COLUMN myarguments VARCHAR(255)");  

How can I also create indexes while adding new column?

like image 967
Emerson Maningo Avatar asked Jan 21 '13 02:01

Emerson Maningo


1 Answers

combine it adding comma, eg

ALTER TABLE mytable      ADD COLUMN myarguments VARCHAR(255),      ADD INDEX (myarguments); 
  • SQLFiddle Demo
like image 146
John Woo Avatar answered Oct 31 '22 01:10

John Woo