If you have already created your MySQL database and table and suddenly realize that one or more table columns need to be modified, you can either drop / delete / remove the respective column and create new or you can alter the table. Altering of the table can be done using any MySQL GUI Tool / Editor like MySQL Query Browser (for Windows) or Sequel Pro (for Mac OSX) or using a MySQL ALTER TABLE Query.
MySQL Query Browser
Right click on the table name in the right panel of MySQL Query Browser and click on Edit Table.
In the Edit Table dialogue box slowly double click on table column name to modify, once the modifications are done click on Apply and Close.
Sequel Pro
Select the table name from left panel and click on Structure in the right panel.
Slowly double click on the column you want to modify, do the required modification and click somewhere outside the column area, changes will be saved.
MySQL ALTER Table Query
Syntax
[bash]
ALTER TABLE tablename CHANGE oldname newname BIGINT (20);
[/bash]
Example
[bash]
ALTER TABLE tbl_admin_modules CHANGE id id1 BIGINT (20);
[/bash]
The above query will rename the column id to id1 and change the column data type to BIGNT (20).
Leave a Reply