前0个消失了吗? [英] First 0 disappearing?

查看:81
本文介绍了前0个消失了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我如何告诉phpmyadmin,MySQL允许电话号码前的前0个? (不是零填充)

How do I tell phpmyadmin, MySQL to allow the first 0 in front of a phone number for example ? (Not a zero fill)

  • 当我尝试在其前面放置零(在phpmyadmin中)时,它会自动将其删除.
  • 当我提交表格号时,在该表格号前面指定0时,它不会添加.

有什么解决方法吗?

推荐答案

mysql中的INT数据类型仅存储一个整数.正如您希望使用任何一种编程语言使用整数数据类型一样,数据库引擎会修剪掉所有的前导零并舍入任何小数点,使其不适合存储电话号码.

The INT datatype in mysql stores just that, an integer. As you would expect with the integer datatype in any programming language, the database engine trims off any leading zeros and rounds any decimal points, making it inappropriate for storing phone numbers.

如果电话号码中的位数始终相同,请改用数据类型CHAR(length),或者不使用数据类型VARCHAR(max_length).这些将存储输入的确切值,而不是整数值.

If the number of digits in the phone number is always the same, use the datatype CHAR(length) instead, or if it's not use the datatype VARCHAR(max_length). These will store the exact value entered rather than an integer value.

这篇关于前0个消失了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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