In SQL how do I get the maximum value for an integer?

Posted by CoffeeMonster on Stack Overflow See other posts from Stack Overflow or by CoffeeMonster
Published on 2010-04-20T22:13:11Z Indexed on 2010/04/20 22:33 UTC
Read the original article Hit count: 148

Filed under:
|

Hi,

I am trying to find out the maximum value for an integer (signed or unsigned) from a MySQL database. Is there a way to pull back this information from the database itself?

Are there any built-in constants or functions I can use (either standard SQL or MySQL specific).

At http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html it lists the values - but is there a way for the database to tell me.

The following gives me the MAX_BIGINT - what I'd like is the MAX_INT.

SELECT CAST( 99999999999999999999999 AS SIGNED ) as max_int;
# max_int | 9223372036854775807

Thanks in advance,

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql