热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

什么是SQLInt(N)的大小?-WhatsthesizeofanSQLInt(N)?

Simplequestion.IhavetriedsearchingonGoogleandafterabout6searches,Ifigureditwouldbe

Simple question. I have tried searching on Google and after about 6 searches, I figured it would be faster here.

简单的问题。我试过在谷歌搜索,经过大约6次搜索,我觉得这里会更快。

How big is an int in SQL?

SQL中的int有多大?

// table creation statement.
intcolumn INT(N) NOT NULL,
// more table creation statement.

How big is that INT(N) element? What's its range? Is it 2^N or is it N Bytes long? (2 ^ 8N)? Or even something else I have no idea about?

INT(N)元素有多大?它的范围是什么?它是2 ^ N还是N字节长? (2 ^ 8N)?甚至是其他我不知道的东西?

2 个解决方案

#1


12  

It depends on the database. MySQL has an extension where INT(N) means an INT with a display width of 4 decimal digits. This information is maintained in the metadata. The INT itself is still 4 bytes, and values 10000 and greater can be stored (and probably displayed, but this depends how the application uses the result set).

这取决于数据库。 MySQL有一个扩展,其中INT(N)表示INT,显示宽度为4位十进制数。此信息在元数据中维护。 INT本身仍然是4个字节,可以存储10000和更大的值(并且可能会显示,但这取决于应用程序如何使用结果集)。

#2


-1  

That depends entirely on the database engine you are using. But I believe most engines consider the INT/INTEGER types to be 32-bit. Most engines will let you specify the signedness.

这完全取决于您使用的数据库引擎。但我相信大多数引擎认为INT / INTEGER类型是32位。大多数引擎都会让您指定签名。

The actual N only specifies the number of digits. So an unsigned INT(3) has the range of 0-999.

实际N仅指定位数。因此,无符号INT(3)的范围为0-999。


推荐阅读
author-avatar
姑另静乖_606
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有