[英]How do I edit MySQL table column properties with PHP?
I need to edit a field type in a MySQL table.我需要在 MySQL 表中编辑字段类型。 Currently I have this one column set as VARCHAR that I need to change to an INT.
目前,我将这一列设置为 VARCHAR,我需要将其更改为 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?
我如何 go 关于使用 PHP 进行此编辑?
Just execute an ALTER TABLE
statement只需执行
ALTER TABLE
语句
ALTER TABLE tablename MODIFY columnname INT;
In PHP:在 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
.如果您需要该列上的额外属性,例如
NOT NULL
、 PRIMARY KEY
或其他属性,请确保将它们包含在ALTER
语句中,就在数据类型INT
之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.