MySQL BigInt Zerofill 与 int Zerofill?

数据库数据库 2023-08-31 03:03:39 570
摘要: MySQLBigInt和int之间的区别在于INT是32位长,而BIGINT是64位长。以下是一些要点-BigInt占用8个字节的存储空间,而int占用4个字节的存储空间。int占用int(10)的最大值4294967295,而bigint(20)...

MySQL BigInt Zerofill 与 int Zerofill?

MySQL BigInt 和 int 之间的区别在于 INT 是 32 位长,而 BIGINT 是 64 位长。

以下是一些要点 -

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

  • int 占用 int(10) 的最大值 4294967295 ,而 bigint(20) 为 18,446,744,073,709,551,615。

  • BigInt(20) 和 int(10),其中 20 和 10 可用于零填充的宽度显示。< /p>

这里是 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)

以上就是MySQL BigInt Zerofill 与 int Zerofill?的详细内容,更多请关注其它相关文章!