Mysql From enumeration to tinyint problems

I have a table with

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

I launched

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

and I found that all my clients (with "0") are set to 1 when I wait for 0

Could you explain to me what problem please?

Bye

+6
source share
1 answer

Converting ENUM to TINYINT may produce unexpected results, since MySQL will actually store your ENUM as integers. To get the desired result, you should start by converting the column to CHAR(1) , and then go to TINYINT(1) .

+10
source

Source: https://habr.com/ru/post/898355/


All Articles