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 次閱讀

開啟你的 職業

完成課程獲得認證

開始
廣告
© . All rights reserved.