MySQL从枚举到tinyint问题 [英] Mysql From enum to tinyint problems

查看:383
本文介绍了MySQL从枚举到tinyint问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子

`terms_of_payment` enum('0','1') NOT NULL DEFAULT '0' COMMENT ''

我跑步

ALTER TABLE `customer` 
CHANGE `terms_of_payment` `terms_of_payment` TINYINT( 1 ) 
     NOT NULL DEFAULT 0 COMMENT '';

当我等待0时,我发现所有客户(值"0")都设置为1

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).

这篇关于MySQL从枚举到tinyint问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆