Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - Rename Column

Tags:

php

mysql

How to rename mysql column from help to content in my table tbl_help

mysql_query("ALTER TABLE tbl_help " . "CHANGE COLUMN help content;");
like image 304
wow Avatar asked Oct 31 '09 20:10

wow


2 Answers

You've got to include the definition of the column in the change column statement (not sure why, but that's what the documentation says.)

So this should work:

mysql_query("ALTER TABLE tbl_help " . "CHANGE COLUMN help content VARCHAR(200) ;");
like image 133
Thorsten Avatar answered Sep 17 '22 09:09

Thorsten


From mySql Doc pages:

You can rename a column using a CHANGE old_col_name new_col_name column_definition clause.

like image 41
psychotik Avatar answered Sep 21 '22 09:09

psychotik