MySQL BigInt zerofill vs int zerofill?

MySQLMySQLi Database

The difference between MySQL BigInt and int is that INT is a 32-bit long while BIGINT is 64-bit long.

The following are some of the points −

  • The BigInt takes 8 bytes of storage while int takes 4 bytes of storage.

  • The int takes 4294967295 maximum values for int(10), whereas 18,446,744,073,709,551,615 for the bigint(20).

  • The BigInt(20) and int(10), in this 20 and 10 can be used for width display with zerofill.

Here is the demo of Bigint and int with zerofill. The following is the query to create a table.

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

Now you can insert records in the table. The query is as follows −

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

Display all records from the table with the help of select statement. The query is as follows −

mysql> select *from BigintandintDemo;

The following is the output −

| Number1              | Number2    |
| 00000000234556667777 | 0000678999 |
1 row in set (0.00 sec)
Published on 11-Jan-2019 14:38:10