Max Size of a MySQL UNSIGNED BIGINT(20) Relating to Hibernate

| No TrackBacks
Just for grins, I decided to run a few tests to determine the max size of an UNSIGNED BIGINT(20).  I use several databases where Hibernate's OBJ_VERSION field is defined as an UNSIGNED BIGINT(20), and I was curious to see how MySQL behaves with very large numbers.  As it turns out, the max size of an UNSIGNED BIGINT(20) is "18,446,744,073,709,551,615" ...

mysql> UPDATE colors SET c_name = 'Blue',
OBJ_VERSION = 18446744073709551615
WHERE c_code = 'BLU';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> UPDATE colors SET c_name = 'Blue',
OBJ_VERSION = 18446744073709551616
WHERE c_code = 'BLU';
ERROR 1264 (22003): Out of range value for column 'OBJ_VERSION' at row 1

I thought that MySQL might "wrap the value" around back to zero if you try to UPDATE with a value greater than the column's max.  But, it definitely does not.  In my case, this is probably not too important because in order to reach 18,446,744,073,709,551,615 Hibernate would have to pound on one specific database record over a quintillion (10^18) times.

It seems a little presumptuous, but I guess Hibernate operates on the assumption that a real database would never reach this limit?  Anyways, I thought this was interesting.  If you'd like to read more about Hibernate's version'ing scheme (that OBJ_VERSION thing I'm talking about) check this out.

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.