tinyint(3) smallint(5), mediumint(7) int(10) bigint(15)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bilibytes
    New Member
    • Jun 2008
    • 128

    tinyint(3) smallint(5), mediumint(7) int(10) bigint(15)

    tinyint(3) smallint(5), mediumint(7) int(10) bigint(15)

    what are the nubers refering to?

    bits or bytes?

    that is to say:

    tinyint(3) means i can store a number between ( 0 and 7 ) or (0 and 1677721) ??


    cheers
  • chazzy69
    New Member
    • Sep 2007
    • 196

    #2
    not 100% sure but i think number in the bracket (X) is refer to how many digits long your integer can be.

    i.e. integer (7) you could have a integer with 7 digits

    => 1234567

    Comment

    • bilibytes
      New Member
      • Jun 2008
      • 128

      #3
      Originally posted by chazzy69
      not 100% sure but i think number in the bracket (X) is refer to how many digits long your integer can be.

      i.e. integer (7) you could have a integer with 7 digits

      => 1234567
      I'm almost sure that the numbers are represented in binary, i won't put my hand on fire but it think that the answer lies between my two propositions. And having done the calculation i think that the numbers refer to bytes.

      if it were bits:
      the maximum number allowed would be bigint(15) = 111111111111111 = 65,535
      and that is not much..

      however being bytes:
      the maximum number would be : enormous!!

      that said if my deduction is right, i have been wasting a lot of space when declaring my tables with bigint(15)...

      if you can confirm that your statement is true, please let me know.

      Comment

      • chazzy69
        New Member
        • Sep 2007
        • 196

        #4
        Oh hi again well for my mysql database (using phpmyadmin to manage) the number in the brackets defines length as number of chars so if i you set int(3) then try to save a 5 digit number it will take the first 3 digits and truncate the rest.

        This is something you have to be careful of if you are storing strings within your database otherwise you will start loosing data if its not long enough.

        Mabye different for yours, good luck :)

        Comment

        • bilibytes
          New Member
          • Jun 2008
          • 128

          #5
          hi,
          i have found an article that may clarify a little.
          by the way, it's amazing when you type bigint(15) in google, this post pops out! i don't know which to congrat, google or bytes but if it's bytes I'm astonished.

          cheers

          Comment

          • chazzy69
            New Member
            • Sep 2007
            • 196

            #6
            Ah nice it only affects the display width, strangely still seems to affect php when it trys to read a value from mysql it will normally end up being to short.

            Good explanation though

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              To clarify:

              As explained in the manual, the number specified inside the parentheses of integer fields does NOT affect the actual storage capacity of the field, as is the case with string types.

              They just set a display width that can be used by applications if they so choose.

              The only real effect this has inside MySQL is if the field is also created with the ZEROFILL option, in which case MySQL returns the field padded to the display width using zeros.

              Comment

              Working...