What is the difference between tinyint, smallint, mediumint, bigint and int in MySQL?
In what cases should these be used?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They take up different amounts of space and they have different ranges of acceptable values.
Here are the sizes and ranges of values for SQL Server, other RDBMSes have similar documentation:
NUMBERdatatype really)Turns out they all use the same specification (with a few minor exceptions noted below) but support various combinations of those types (Oracle not included because it has just a
NUMBERdatatype, see the above link):And they support the same value ranges (with one exception below) and all have the same storage requirements:
The “unsigned” types are only available in MySQL, and the rest just use the signed ranges, with one notable exception:
tinyintin SQL Server is unsigned and has a value range of 0 to 255