BIGINT(8)是MySQL能存储的最大整数吗?


在BIGINT(8)中,编号8表示数据将如何显示。它不会影响存储。该编号用于显示宽度。

BIGINT占用8个字节,即64位。有符号范围为-9223372036854775808到9223372036854775807,无符号范围采用正值。无符号的范围为0到18446744073709551615。

为了理解bigint(8),我们创建一个具有BIGINT(8)和zerofill列的表格−

mysql> create table BigIntDemo8
   -> (
   -> Number1 BIGINT(8) not null,
   -> Number2 BIGINT(8) unsigned zerofill not null
   -> );
Query OK, 0 rows affected (0.59 sec)

为这两列插入一些记录。插入记录的查询如下−

mysql> insert into BigIntDemo8 values(1,1);
Query OK, 1 row affected (0.14 sec)

mysql> insert into BigIntDemo8 values(11,11);
Query OK, 1 row affected (0.24 sec)

mysql> insert into BigIntDemo8 values(111,111);
Query OK, 1 row affected (0.14 sec)

mysql> insert into BigIntDemo8 values(1111,1111);
Query OK, 1 row affected (0.18 sec)

mysql> insert into BigIntDemo8 values(11111,11111);
Query OK, 1 row affected (0.10 sec)

mysql> insert into BigIntDemo8 values(111111,111111);
Query OK, 1 row affected (0.21 sec)

使用select语句从表格中显示所有记录。查询如下−

mysql> select *from BigIntDemo8;

以下是输出−

+---------+----------+
| Number1 | Number2  |
+---------+----------+
|       1 | 00000001 |
|      11 | 00000011 |
|     111 | 00000111 |
|    1111 | 00001111 |
|   11111 | 00011111 |
|  111111 | 00111111 |
+---------+----------+
6 rows in set (0.00 sec)

更新日期:2019年7月30日

3K+浏览量

开启你的 职业

通过完成课程获得认证

开始吧
广告
© . All rights reserved.