Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com The diference between tinyint(4) and tinyint(3)?

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 01-13-2013, 03:54 PM PM User | #1 milanello72 New Coder   Join Date: Feb 2012 Posts: 24 Thanks: 0 Thanked 0 Times in 0 Posts The diference between tinyint(4) and tinyint(3)? 1. What is tinyint(4)? 2. Is 4 the number of digits? 3. Could you tell me the diference between tinyint(4) and tinyint(3)? 4. Is it possible to have tinyint(7) ? Thank u very much!
 01-13-2013, 05:27 PM PM User | #2 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,591 Thanks: 4 Thanked 2,597 Times in 2,566 Posts The 4 in the tinyint should represent the zerofill of the number. You can have a tinyint(50) if you want. All that changes is the left padding of 0's that appear before the number stored. So tinyint(4) with a value of 56 would be 0056. It won't alter the range you are allowed. I believe that the zerofill only works with unsigned numbers, so with a tinyint you can still only have 0 - 255 as a valid range. Edit: After a quick test the number does represent the display range regardless of signed/unsigned. It does not however appear to allow zerofill unless the number is unsigned, so if you were to set tinyint(0) that would result in tinyint(3) since you need three digits to display the range of tinyint. When its signed, it gives me tinyint(4). So it will automatically dictate the minimum size for you based on the datatype and sign, but anything above and beyond is for zerofill. This would also indicate that it merely represents the number of chars required to display it, rather than to store it (since a tinyint can fit in a single byte). Last edited by Fou-Lu; 01-13-2013 at 05:33 PM..
 01-13-2013, 09:03 PM PM User | #3 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,941 Thanks: 75 Thanked 4,306 Times in 4,273 Posts And zerofill is, in my opinion, a bad idea. It gives the mistaken impression that MySQL is actually storing numbers with leading zeroes. Nothing could be further from the truth! INTERNALLY, there is NO DIFFERENCE between TINYINT(0) and TINYINT(50). The *ONLY* difference is that, when you SELECT a field declared as TINYINT(50) ZEROFILL, MySQL must convert the *NUMBER* in the field to a *STRING*! Because ONLY strings can actually have zero fill. On top of all that, when you USE a ZEROFILL field in a server-side language, such as PHP or ASP or JSP, you many be surprised at what the actual value is. At least in ASP, for example, the zero fill is *REMOVED* from the number and the number is treated as a DOUBLE (a.k.a. REAL) number, not as an integer, at all. So the best thing you can do, in my opinion, is *NEVER* use ZEROFILL. __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 06:53 AM.