开发者

How do I edit MySQL table column properties with PHP?

开发者 https://www.devze.com 2023-03-19 14:07 出处:网络
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 pane

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

精彩评论

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