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

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)

阅读更多:MySQL 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程