mysql从枚举类型enum用CHANGE转换为tinyint类型时,可能报错,解决方案如下:

ALTER  TABLE `tao_auth_rule` CHANGE `ismenu` `ishidden` tinyint(1) NOT NULL DEFAULT 1 COMMENT '0目录1菜单,2按钮';

and I found all my customers (with '0' value) set to 1 when I'm waiting 0

Could you explain me, what's the trouble, please ?

解决方案

将ENUM转换为TINYINT可能会产生意外的结果,因为MySQL实际上已经以整数的形式存储了ENUM。要获得想要的结果,实际上应该先将列转换为CHAR(1),然后转到TINYINT(1)。

Converting the ENUM to TINYINT might give unexpected results, as MySQL will actually already store your ENUM in the form of integers. To get the result you want, you should actually start by converting your column to a CHAR(1) and then go to TINYINT(1).