当您更改表时,如何检测列的数据类型?
我正在运行 MySQL,我需要将某些列的数据类型从枚举更改为整数。然而,有很多列。 (如果存在)同时更改所有枚举列的语法是什么。以下是我更新单个列以使其成为整数数据类型的方法:
ALTER TABLE table_name CHANGE column_name column_name INTEGER;
I am running MySQL and I need to change the data type of certain columns from an enumeration to integer. However, there are a lot of columns. (If this exists) What is the syntax to alter all columns at the same time that are enumerations. Here is how I am updating a single column to make it integer data type:
ALTER TABLE table_name CHANGE column_name column_name INTEGER;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SHOW COLUMNS FROM WHERE TYPE LIKE "%enum%"
之后您可以迭代结果,类似于此处描述的解决方案:
https://www.php.net/manual/ en/function.mysql-fetch-field.php#92069
希望这有帮助,
迈克尔
SHOW COLUMNS FROM WHERE TYPE LIKE "%enum%"
you could afterwards iterate through your result similar to the solution described here:
https://www.php.net/manual/en/function.mysql-fetch-field.php#92069
hope this helps,
Michael