MySQL 中 BIGINT 和 BIGINT(20) 的區別是什麼?
BIGINT 和 BIGINT(20) 之間的唯一區別在於顯示寬度。20 可用於顯示寬度。
我們來看一個例子並建立一個表。這裡,我們設定了 BIGINT(20) -
mysql> create table DemoTable ( Number bigint(20) zerofill ); Query OK, 0 rows affected (0.58 sec)
使用 insert 命令在表中插入一些記錄 -
mysql> insert into DemoTable values(1); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(12); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(123); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(1234); Query OK, 1 row affected (0.11 sec)
使用 select 語句顯示錶中的所有記錄 -
mysql> select *from DemoTable;
這會產生以下輸出。寬度現在為 20,因此數字會擴充套件並可見,如下所示 -
+----------------------+ | Number | +----------------------+ | 00000000000000000001 | | 00000000000000000012 | | 00000000000000000123 | | 00000000000000001234 | +----------------------+ 4 rows in set (0.00 sec)
廣告