问题描述
我有一列 integer 类型的列,长度为 10:
I have a column of type integer with length 10:
`some_number` int(10) unsigned NOT NULL
我在此列中插入了一个太长的数字:
Into this column I insert a number that is too long:
$some_number = 715988985123857;
$query = "INSERT INTO this_table SET some_number = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('i', $some_number);
$stmt->execute();
当我查看表格中的内容时,现在的数字是:
When I look at what is in the table, the number is now:
2147483647
715988985123857如何以及为什么变成2147483647?
为什么它没有被截断?
这种转换背后的机制是什么,可以用一些公式计算得到的数字吗?
How and why did 715988985123857turn into 2147483647?
Why didn't it get truncated?
What is the mechanism behind this transformation, and can the resulting number be calculated with some formula?
我不是在寻找解决方案.我只是想了解具体的数字.
I'm not looking for a solution. I just want to understand the specific number.
推荐答案
http://dev.mysql.com/doc/refman/5.0/en/integer-types.html
整数溢出会将DB中的最大允许数设置为
The integer overflow will set the max allowed number in the DB as
2147483647
所以你需要 bigint 数据类型来存储更大的整数
So you need bigint datatype for storing bigger integer
这篇关于长整数在插入较短的列时进行转换,而不是截断.为什么?公式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)