MySQL中BIGINT和BIGINT(20)之间的区别?

BIGINT和BIGINT(20)之间的唯一区别是显示宽度。20可用于显示宽度。

让我们看一个示例并创建一个表。在这里,我们设置了BIGINT(20)-

mysql> create table DemoTable
(
   Number bigint(20) zerofill
);

使用插入命令在表中插入一些记录-

mysql> insert into DemoTable values(1);
mysql> insert into DemoTable values(12);
mysql> insert into DemoTable values(123);
mysql> insert into DemoTable values(1234);

使用select语句显示表中的所有记录-

mysql> select *from DemoTable;

这将产生以下输出。现在的宽度为20,因此数字会扩展并可见,如下所示-

+----------------------+
| Number               |
+----------------------+
| 00000000000000000001 |
| 00000000000000000012 |
| 00000000000000000123 |
| 00000000000000001234 |
+----------------------+
4 rows in set (0.00 sec)