开发者

When you alter a table how do you detect the data type of columns?

开发者 https://www.devze.com 2023-01-13 09:09 出处:网络
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 a

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 updati开发者_如何转开发ng a single column to make it integer data type:

ALTER TABLE table_name CHANGE column_name column_name INTEGER;


SHOW COLUMNS FROM WHERE TYPE LIKE "%enum%"

you could afterwards iterate through your result similar to the solution described here: http://se2.php.net/manual/en/function.mysql-fetch-field.php#92069 hope this helps, Michael

0

精彩评论

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

关注公众号