I need to rename columns in my MySQL table using PHP.
This is made difficult because the syntax is ALTER TABLE [table] CHANGE COLUMN [oldname] [newname] [definition]. The definition is a required parameter.
Is there a way to grab the definition and simply feed this back into the SQL statement? Some sample code would be fantastic, thanks!
According to http://codingforums.com/showthread.php?t=148936, you may have to parse the results of
SHOW CREATE TABLEto get the current definition, then use that in theALTERstatement.mysql_fetch_field() may be useful also.