MYSQL中int(11)数据类型面临的问题 [英] Issues faced with int(11) datatype in MYSQL

查看:670
本文介绍了MYSQL中int(11)数据类型面临的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MYSQL中有一个表,主键id为int(11)(自动递增)。现在我有一个程序读取一些文本文件并在id列中输入值。
所以我的表应该包含:

I have a table in MYSQL in with a primary key id int(11) (auto-incremented). Now I have a program which reads some text file and enters the value in id column. So my table should contains :

id
897413
791783


但是会发生什么,我可以在我的桌子上找不到大数字。这是因为int(11)可以容纳的最大值吗?将int(11)增加到int(20)仍然面临同样的问题。我无法将数据类型更改为big int,因为我已经实现了很多代码。

But what happens is that, I can't find big numbers in my table. Is this because of maximum value that int(11) can hold? Increased int(11) to int(20) still facing same problem. I can't change the datatype to big int as I have already implemented a lot of code.

编辑:
我试图插入一条带id的记录as 523826,它在DB中保存为450258.为什么会这样?

I tried to insert a single record with id as 523826 and it got saved in DB as 450258. Why so?

推荐答案

int 的dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html\"rel =noreferrer> mysql手册数据类型:

Definition from mysql manual for the int data type:


正常大小的整数。符号范围是-2147483648到2147483647.无符号范围是0到4294967295。

A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

int type总是4个字节(32位)。 int(11)中的 11 只是显示宽度,只对 UNSIGNED ZEROFILL 列。有关此博文的详细信息。

The int type is always 4 bytes (32 bits). The 11 in int(11) is just the "display width", that only matters for UNSIGNED ZEROFILL columns. More details on this blog post.

这篇关于MYSQL中int(11)数据类型面临的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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