Jump to content


Photo

MySql Int data type


  • Please log in to reply
4 replies to this topic

#1 Mateobus

Mateobus
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 08 August 2006 - 01:13 AM

I thought that in a MyISAM table, if i use an int type and specify a length of 4, it will allow values up to 9999.  This is wrong apparently as the table only help up to 127.  So what is this length based on?  How big will an int of length 10 hold?3?  Thanks for the help.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 08 August 2006 - 06:36 AM

Have you used INT or TINYINT?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 August 2006 - 01:00 PM

When you specifiy the length it means the length of the number, so if its 4 it'll accept upto a 4 digit number, where as 10 will allows upto a 10 digit number.

#4 Mateobus

Mateobus
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 08 August 2006 - 01:50 PM

I did tinyint (4).  Is this unacceptable?

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 August 2006 - 01:59 PM

No. Tinyint can only hold an Integer that is between -128 and 127 when it is signed. If its unsigned it can hold an integer between 0 and 255
Have a look at the Data Types column in this cheat sheat to see what each data type can hold




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users