Mysql的BigInt(20),Int(20)以及Bigint(32)有区别吗?
原文: http://stackoverflow.com/questions/3135804/types-in-mysql-bigint20-vs-int20-etcc
http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html
Types in MySQL: BigInt(20) vs Int(20) etcc
See http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html
INT is a four-byte signed integer. BIGINT is an eight-byte signed integer.
The 20 in INT(20) and BIGINT(20) means almost nothing. It's a hint for display width, it has nothing to do with storage. Practically, it affects only the ZEROFILL option:
- CREATE TABLE foo ( bar INT(20) ZEROFILL );
- INSERT INTO foo (bar) VALUES (1234);
- SELECT bar from foo;
- +----------------------+
- | bar |
- +----------------------+
- | 00000000000000001234 |
- +----------------------+
The number in parentheses in a type declaration is display width , which is unrelated to the range of values that can be stored in a data type. Just because you can declare Int(20) does not mean you can store values up to 10^20 in it:
[...] This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. ...
The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range allowed by three characters are displayed using more than three characters.
For a list of the maximum and minimum values that can be stored in each MySQL datatype, see here .

一个INT,占4个字节,跟JAVA中的int一样,即使是有符号也能表达21亿 这么大的数据。 所以平时绝大多数情况,包括大型网站的UID,都用不了这么大的数据,好友关系表可能会超过,关系表可以考虑用BIGINT。还有就是平时时间戳需要用BIGINT。总之,不要轻易用上BIGINT,完全是浪费!
Mysql的BigInt(20),Int(20)以及Bigint(32)有区别吗?的更多相关文章
- mysql中bigint、int、mediumint、smallint 和 tinyint的取值范围
mysql数据库设计,其中,对于数据性能优化,字段类型考虑很重要,搜集了些资料,整理分享出来,这篇为有关mysql整型bigint.int.mediumint.smallint 和 tinyint的语 ...
- MySQL整数类型说明 int(11) vs int(20)
整数类型后面跟的是显示的宽度.M指示最大显示宽度.最大有效显示宽度是255.显示宽度与存储大小或类型包含的值的范围无关. 实践出真知: mysql> create table test2 ( a ...
- mysql中bigint、int、mediumint、smallint与tinyint的取值范围
https://blog.csdn.net/github_39110707/article/details/74277381 mysql数据库设计,其中对性能优化,字段类型很重要,下面对bigint. ...
- MYSQL性能优化的最佳20+条经验
MYSQL性能优化的最佳20+条经验 2009年11月27日 陈皓 评论 148 条评论 131,702 人阅读 今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数 ...
- Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50096, now running 50173.
IDEA链接mysql提示 Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50096, ...
- 如何将生产环境的字段类型从INT修改为BIGINT
介绍 改变数据类型是一个看起来很简单的事情,但是如果表非常大或者有最小停机时间的要求,又该如何处理那?这里我提供一个思路来解决这个问题. 背景 在一个常规SQL Server heath检查中,使用s ...
- tinyint、smallint、bigint、int 区别
1byte=8bit [tinyint] 从 0 到 255 的整型数据.存储大小为 1 字节.如果设置为UNSIGNED类型,只能存储从0到255的整数,不能用来储存负数. [smallint] ...
- column count of mysql.proc is wrong. expected 20,found 16. the table is probably corruptd.
1558 1547 column count of mysql.proc is wrong. expected 20,found 16. the table is probably corruptd. ...
- SQLServer bigint 转 int带符号转换函数(原创)
有一个需求是要在一个云监控的状态值中存储多个状态(包括可同时存在的各种异常.警告状态)使用了位运算机制在一个int型中存储. 现在监控日志数据量非常大(亿级别)需要对数据按每小时.每天进行聚合,供在线 ...
随机推荐
- 66-Flutter移动电商实战-会员中心_编写ListTile的通用方法
1.界面分析 通过下图我们可以拆分成 4 部分,头部.订单标题区域.订单列表区域.ListTitle同用部分. 2.UI编写 2.1.头部 主要用到了圆形头像裁剪组件-ClipOval 顶部头像区域W ...
- Xamarin.Forms快速入门-深入探讨
官网链接 项目介绍 以Notes项目为例,The Notes application consists of one solution containing four projects, as sho ...
- netflix flamescope 方便的不同时间范围的火焰图查看工具
flamescope 是netflix 开源的方便的火焰图查看工具,我们可以选择不同时间范围的数据,方便分析调用链 环境准备 使用docker-compose运行,基于官方的dockerfile 创建 ...
- Promise对异步编程的贡献以及基本API了解
异步: 核心: 现在运行的部分和将来运行的部分之间的关系 常用方案: 从现在到将来的等待,通常使用一个回调函数在结果返回时得到结果 控制台(因为console族是由宿主环境即游览器实现的)可能会使用异 ...
- 关于wineQQ8.9.19983deepin23版本提升不能在使用请升级,Linux偷懒升级方法
安装wineQQ8.9.19983deepin23版本后提示,不在提供服务请升级. 第一步 前往QQ官方下载Windows最先版本QQ https://qd.myapp.com/myapp/qqtea ...
- player: 初始化分析
//1. //cocos 程序开始运行时执行的函数 bool AppDelegate::applicationDidFinishLaunching() { // initialize director ...
- springboot(1)@SpringBootApplication
首先来看下Spring Boot项目中的运行类,基本上每个项目都会有该启动类: @SpringBootApplication public class Application { public sta ...
- Spring 中的事件机制
说到事件机制,可能脑海中最先浮现的就是日常使用的各种 listener,listener去监听事件源,如果被监听的事件有变化就会通知listener,从而针对变化做相应的动作.这些listener是怎 ...
- save tracking results into csv file for oxuva long-term tracking dataset (from txt to csv)
save tracking results into csv file for oxuva long-term tracking dataset (from txt to csv) 2019-10-2 ...
- Tensorflows安装(cpu版安装方法)
一.说明 首先声明,本人系统是Windows10 64位,Win7未试. 本文旨在帮助园友以更简单的方式安装Tensorflow,下面介绍的是如何安装Python的Tensorflow cpu版本. ...