Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 766793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T17:06:20+00:00 2026-05-14T17:06:20+00:00

I am trying to find out the maximum value for an integer (signed or

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T17:06:20+00:00Added an answer on May 14, 2026 at 5:06 pm

    In Mysql there is a cheap trick to do this:

    mysql> select ~0;
    +----------------------+
    | ~0                   |
    +----------------------+
    | 18446744073709551615 |
    +----------------------+
    

    the tilde is the bitwise negation. The resulting value is a bigint. See: http://dev.mysql.com/doc/refman/5.1/en/bit-functions.html#operator_bitwise-invert

    For the other integer flavours, you can use the right bitshift operator >> like so:

    SELECT ~0 as max_bigint_unsigned
    ,      ~0 >> 32 as max_int_unsigned
    ,      ~0 >> 40 as max_mediumint_unsigned
    ,      ~0 >> 48 as max_smallint_unsigned
    ,      ~0 >> 56 as max_tinyint_unsigned
    ,      ~0 >> 1  as max_bigint_signed
    ,      ~0 >> 33 as max_int_signed
    ,      ~0 >> 41 as max_mediumint_signed
    ,      ~0 >> 49 as max_smallint_signed
    ,      ~0 >> 57 as max_tinyint_signed
    \G
    
    *************************** 1. row ***************************
       max_bigint_unsigned: 18446744073709551615
          max_int_unsigned: 4294967295
    max_mediumint_unsigned: 16777215
     max_smallint_unsigned: 65535
      max_tinyint_unsigned: 255
         max_bigint_signed: 9223372036854775807
            max_int_signed: 2147483647
      max_mediumint_signed: 8388607
       max_smallint_signed: 32767
        max_tinyint_signed: 127
    1 row in set (0.00 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find out if there is any way to elevate a specific
I am trying to find out how to upload a file from a web
I am trying to find out how much memory my application is consuming from
I'm trying to find out the most efficient (best performance) way to check date
Im trying to find out a good JavaScript library that can create a nice
I'm trying to find out how much memory my own .Net server process is
I'm trying to find out the 'correct' windows API for finding out the localized
I'm trying to find out whether I should be using business critical logic in
I'm trying to find out how much memory my objects take to see how
I am trying to find out how to use usercontrols in asp.net mvc. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.