Reputation: 9787
I am trying to change the name of the column c to novaC with php and mysql. Everywhere I look seems to give the same solution but it doesn't seem to work:
if(isset($_GET["rename"])){
mysql_query("ALTER TABLE myTable
RENAME COLUMN c to novaC");
}
If I type: ALTER TABLE aaa RENAME COLUMN c to novaC
directly in MySql it gives:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLUMN c to novaC' at line 2
Upvotes: 2
Views: 14641
Reputation: 31417
alter table tablename change oldColumn newColumn varchar(10) ;
Reference : Alter Table - MySQL Command
Upvotes: 5
Reputation: 10030
if(isset($_GET["rename"])){
mysql_query("ALTER TABLE myTable CHANGE c novaC varchar(9999)");
}
Upvotes: 5