MySQL BigInt zerofill 与 int zerofill?


MySQL BigInt 与 int 之间存在的区别在于,INT 为 32 位长,而 BIGINT 为 64 位长。

以下是部分要点 −

  • BigInt 占用 8 个字节的存储空间,而 int 占用 4 个字节的存储空间。

  • int 取值最大为 4294967295(对于 int(10)),而 bigint(20) 取值最大为 18,446,744,073,709,551,615。

  • 对于 BigInt(20) 和 int(10),可以将这 20 和 10 用于用 zerofill 显示宽度。

以下是使用 zerofill 的 BigInt 和 int 演示。以下查询用于创建一个表。

mysql> create table BigintandintDemo
   −> (
   −> Number1 bigint zerofill,
   −> Number2 int zerofill
   −> );
Query OK, 0 rows affected (0.62 sec)

现在可以在表中插入记录。查询如下 −

mysql> insert into BigintandintDemo values(234556667777,678999);
Query OK, 1 row affected (0.17 sec)

借助 select 语句显示表中的所有记录。查询如下 −

mysql> select *from BigintandintDemo;

以下是输出 −

+----------------------+------------+
| Number1              | Number2    |
+----------------------+------------+
| 00000000234556667777 | 0000678999 |
+----------------------+------------+
1 row in set (0.00 sec)

更新日期: 30-Jul-2019

213 次阅读

开启你的 职业

完成课程获得认证

开始
广告