sql - BIGINT(8) 是 MySQL 可以存储的最大整数吗?

我现在有一些数字超出了 INT 的处理能力。

这有点尴尬,但我真的不知道 BIGINT(8) 到底是什么意思。其中的8是最大位值还是最大长度?

所以 BIGINT(1) 只能是一位数?或者是 BIGINT(1) 别的什么?我认为 TINYINT(1) 最大值是 127,结果如何?

  • BIGINT我能做的最大的事情是什么?
  • 我可以在 MySQL 中以整数形式存储的最大数字是多少?

最佳答案

数字代表它的显示方式 - 它不影响数据的存储方式。

来自 the manual :

Another extension is supported by MySQL for optionally specifying the display width of integer data types in parentheses following the base keyword for the type (for example, INT(4)). 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. (That is, this width is present in the metadata returned with result sets. Whether it is used or not is up to the application.)

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.

BIGINT 始终为 8 个字节,可以存储 -9223372036854775808 到 9223372036854775807(有符号)或 0 到 18446744073709551615(无符号)。

https://stackoverflow.com/questions/1632312/

相关文章:

php - MySQL 查询随机滞后

php - Laravel OrderBy 关系计数

mysql - ON UPDATE RESTRICT 有什么作用?

php - 将大量点击记录到 MySQL 数据库中的最佳实践

mysql - 如何同步开发和生产数据库

php - 一次查询 MySQL 插入多行

mysql - 错误 2002 (HY000) : Can't connect to local M

php - 如何使用 laravel 连接 mysql?

php - Doctrine2 迁移向下迁移并从浏览器而不是命令行迁移

mysql - 如何在 MySQL 的命令行中显示变量的值?