tags:

views:

112

answers:

2

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

mysql_query("ALTER TABLE tbl_help " . "CHANGE COLUMN help content;");
+2  A: 

From mySql Doc pages:

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

psychotik
thanks for the page. sorry, what is the column_definition? it's syntax like TEXT INT etc?
bob
Yes, it's the type, constraints, etc. See http://dev.mysql.com/doc/refman/5.1/en/create-table.html for the exact definition.
Lukáš Lalinský
@bob check the doc?
Mike B
It's the column type, length, charset etc.
@Mike B - Yeah.. getting blur. Actually I could not understand without fully examples.
bob
This is all well and good, but does it screw up foreign keys, indexes and constraints?
rik.the.vik
+2  A: 

You've got to include the definition of the table 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) ;");
IronGoofy