In BIGINT(8), the number 8 represents how the data will be displayed. It does not affect the storage. The number is used to display width.
BIGINT takes 8 bytes i.e. 64 bits. The signed range is -9223372036854775808 to 9223372036854775807 and unsigned range takes positive value. The range of unsigned is 0 to 18446744073709551615.
To understand bigint(8), let us create a table with BIGINT(8) and zerofill column −
mysql> create table BigIntDemo8 -> ( -> Number1 BIGINT(8) not null, -> Number2 BIGINT(8) unsigned zerofill not null -> ); Query OK, 0 rows affected (0.59 sec)
Insert some records for both the columns. The query to insert record is as follows −
mysql> insert into BigIntDemo8 values(1,1); Query OK, 1 row affected (0.14 sec) mysql> insert into BigIntDemo8 values(11,11); Query OK, 1 row affected (0.24 sec) mysql> insert into BigIntDemo8 values(111,111); Query OK, 1 row affected (0.14 sec) mysql> insert into BigIntDemo8 values(1111,1111); Query OK, 1 row affected (0.18 sec) mysql> insert into BigIntDemo8 values(11111,11111); Query OK, 1 row affected (0.10 sec) mysql> insert into BigIntDemo8 values(111111,111111); Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from BigIntDemo8;
The following is the output −
+---------+----------+ | Number1 | Number2 | +---------+----------+ | 1 | 00000001 | | 11 | 00000011 | | 111 | 00000111 | | 1111 | 00001111 | | 11111 | 00011111 | | 111111 | 00111111 | +---------+----------+ 6 rows in set (0.00 sec)