Data type for IP Address converted using INET_ATON()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akapsycho
    New Member
    • Aug 2007
    • 43

    Data type for IP Address converted using INET_ATON()

    Is it INT(10)? I've done some reading and found out that INET_ATON() should make my MySQL queries fastest, but I'm not sure which data type to store it as.

    As far as I can tell, the maximum value should be: 255×256^3 + 255×256^2 + 255×256^1 + 255 = 4278190080 + 16711680 + 65280 + 255 = 4,294,967,295

    Which means that the best (fastest) data type would be INT(10) UNSIGNED. Am I right?
  • akapsycho
    New Member
    • Aug 2007
    • 43

    #2
    Yes/No?

    Sorry i just want to get this right.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      The best match for that would be a simple INT UNSIGNED.

      The INT type is 4 bytes which according to my calculations, and the MySQL reference manual, has a max value of 4,294,967,295 when it is UNSIGNED.

      The extra (10) to the INT would do nothing but allow the extra 5.71 billion to be stored as well.

      Comment

      • akapsycho
        New Member
        • Aug 2007
        • 43

        #4
        I don't think phpmyadmin lets you specify INT without a length does it?

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Originally posted by akapsycho
          I don't think phpmyadmin lets you specify INT without a length does it?
          I don't know, but not allowing it would be a major flaw. In any case, you could always simply write the query yourself and then run it.

          Comment

          • akapsycho
            New Member
            • Aug 2007
            • 43

            #6
            Alright, cool. Thanks man.

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Heya, Psycho.

              Originally posted by akapsycho
              I don't think phpmyadmin lets you specify INT without a length does it?
              Sure it does.

              VARCHAR and CHAR types do require a length, but numeric types are inherently limited.

              Comment

              Working...