开发者

mySQL field type question

开发者 https://www.devze.com 2023-02-11 01:12 出处:网络
I have db table cell that stores 5-digit zip code, however when the zip starts with 0 it is dropped and only 4 digits are stored. Currently the column 开发者_如何学运维type is set to INT(5), but clear

I have db table cell that stores 5-digit zip code, however when the zip starts with 0 it is dropped and only 4 digits are stored. Currently the column 开发者_如何学运维type is set to INT(5), but clearly this is not working.

What type shall I use instead?

Thanks.


Try using a CHAR(5) data type if it's always going to 5 digits long


Try using int(5) zero fill. Then you get the speed of an int but the zero at the front. I recently had this issue and solved it this way.


CHAR(5) CHARACTER SET ascii COLLATE ascii_bin

0

精彩评论

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