开发者

How do I edit MySQL table column properties with PHP?

I need to edit a field type in a MySQL table. Currently I have this one column set as VARCHAR that I need to change to an INT. 开发者_开发问答 The catch is that I do not have access to the control panel so I cannot simply flip the switch. How do I go about making this edit with PHP?


Just execute an ALTER TABLE statement

ALTER TABLE tablename MODIFY columnname INT;

In PHP:

$result = mysql_query("ALTER TABLE tablename MODIFY columnname INT;");

If you require extra attributes on that column, such as NOT NULL, PRIMARY KEY, or others, be sure to include them in the ALTER statement, just after the data type INT.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜