[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now



Posted on 2004-11-02
Medium Priority
Last Modified: 2008-02-26

In this overview you can see for example:
TINYINT = 0 - 255 (unsigned)
SMALLINT = 0 - 65535 (unsigned)
MEDIUMINT = 0 - 16777215 (unsigned)

Now in my database (MySQL) I use for example
SMALLINT(3) for numbers from 0 -> 999. But lately I saw I could use SMALLINT(1) as well for that...

Can someone clarify this?
Question by:G00fy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 12472021
"But lately I saw I could use SMALLINT(1) as well for that"

Where did you see that?



Author Comment

ID: 12472042
In my database... I was using values of lets say '2300', normally I would use like SMALLINT(4) for that, but lately I saw that when I use SMALLINT(1) as well...

Expert Comment

ID: 12472075
I will be curious to see if anyone has any insight to this as well. I am not sure of the inner workings of MySQL but some logic and some basic math skills would tell you that 2300 can't be stored in one byte. My guess would be that the '1' doesn't represent what it appears to represent.


Author Comment

ID: 12472093
My best guess is that the 1 means like (smallint = 2 bytes), so that it would mean 2bytes x 1
And then it is correct. If this is true however, then I am very stupid as all my indexes on my database are like INT(10) :-)

Accepted Solution

half_life_fool earned 400 total points
ID: 12480902

Another extension is supported by MySQL for optionally specifying the display width of an integer value in parentheses following the base keyword for the type (for example, INT(4)). This optional display width specification is used to left-pad the display of values having a width less than the width specified for the column.

The display width does not constrain the range of values that can be stored in the column, nor the number of digits that will be displayed for values having a width exceeding that specified for the column.

If you specify INT(4), then the storage size will be INT anyway. The 4 just means if you want to display it, it can be zero-padded to that length. (with other words: it doesn't matter that you specify 4 or 1 if you don't concern yourself with display, fe. if only using it in PHP).


Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question