Difference between BIGINT and BIGINT(20) in MySQL?


The only difference between BIGINT and BIGINT(20) is for displaying width. The 20 can be used for displaying width.

Let us see an example and create a table. Here, we have set BIGINT(20) −

mysql> create table DemoTable
(
   Number bigint(20) zerofill
);
Query OK, 0 rows affected (0.58 sec)

Insert some records in the table using insert command −

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)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output. The width is now 20, therefore the number expands and visible like below −

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

Updated on: 07-Oct-2019

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements