Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql difference between bigint and bigint(20)

I know that signed data type holds negative and positive no's AND unsigned holds only positive integer.

But Whats the difference between the two.

bigint unsigned AND bigint(20) unsigned

like image 713
Bharat Pahalwani Avatar asked Aug 30 '25 16:08

Bharat Pahalwani


1 Answers

BIGINT UNSIGNED is an eight-byte unsigned integer.

The 20 in BIGINT(20) means almost nothing. It's a hint for display width, it has nothing to do with storage. Practically, it affects only the ZEROFILL option:

CREATE TABLE foo ( bar INT(20) ZEROFILL );
INSERT INTO foo (bar) VALUES (1234);
SELECT bar from foo;

+----------------------+
| bar                  |
+----------------------+
| 00000000000000001234 |
+----------------------+

It's a common source of confusion for MySQL users to see BIGINT(20) and assume it's a size limit, something analogous to CHAR(20).

like image 199
tofcoder Avatar answered Sep 02 '25 07:09

tofcoder