mysql 中 10 位手机无数据是什么问题? [英] What is the issue with 10 digit mobile no data in mysql?

查看:18
本文介绍了mysql 中 10 位手机无数据是什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个表格来存储我网站用户的联系记录.它还包含一个 10 位数的手机号码.

I made a table for storing contact record of user of my website. It also contains a 10 digit mobile no.

表结构是这样的:

CREATE TABLE contact_user
(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
contact INT(10)
)

现在的问题是,如果我使用 phpmyadmin 在联系人字段中插入 10 个手机号码(例如 9595891256),它会插入一些随机值并显示警告说数据超出列范围"

Now the problem is that if I insert a 10 mobile no.(e.g.9595891256) using phpmyadmin into contact field it will insert some random value and shows a warning saying "data out of column range"

但是如果我插入一个简单的 10 位数字编号(例如 4561327894),那么它运行良好并且不会显示任何警告.

But if I insert a simple 10 digit no (e.g.4561327894) then it works well and no warning is shown.

所以请告诉我在此栏中插入手机号码有什么问题?

SO please tell me what is the issue in inserting a mobile no in this column?

我在 ubuntu 11.04 上使用 mysql 5.1,也使用 phpmyadmin.

I am using mysql 5.1 on ubuntu 11.04 and also using phpmyadmin.

推荐答案

INT(10) 不是 10 位的数字,而是显示宽度为 10 位的整数.无论你放 INT(2) 还是 INT(10),MySQL 仍然只存储一个(无符号,在这种情况下)INT,其最大值为 4294967295.

INT(10) does not mean a 10-digit number, it means an integer with a display width of 10 digits. Whether you put INT(2) or INT(10), MySQL still only stores an (unsigned, in this case) INT which has a maximum value of 4294967295.

您可以使用 BIGINT 而不是 INT 将其存储为数字.但是,我不建议这样做,因为它不允许使用国际号码.如果您确定您的应用程序将只使用美国数字,那么使用 BIGINT 将比 VARCHAR(10) 每行节省 3 个字节——如果您担心这种事情.

You can use a BIGINT instead of INT to store it as a numeric. I wouldn't recommend this, however, because it won't allow for international numbers. If you are certain your application will only use US numbers, using BIGINT will save you 3 bytes per row over VARCHAR(10) -- if that sort of thing concerns you.

由于它是一个电话号码(因此您不会对其进行数字计算),请尝试使用 VARCHAR(20).这使您能够在需要时正确存储国际电话号码.

Since it is a phone number (and therefore you won't be doing numeric calculations against it), try using a VARCHAR(20). This allows you the ability to store international phone numbers properly, should that need arise.

这篇关于mysql 中 10 位手机无数据是什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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