Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between int and integer in MySQL 5.0?

What is the difference between int and integer datatypes in MySQL 5.0? Can anyone help? I don't understand the exact difference.

like image 859
sivakumar Avatar asked Mar 27 '09 04:03

sivakumar


People also ask

Is int and integer same in MySQL?

MySQL supports the SQL standard integer types INTEGER (or INT ) and SMALLINT . As an extension to the standard, MySQL also supports the integer types TINYINT , MEDIUMINT , and BIGINT . The following table shows the required storage and range for each integer type.

What is the difference between an integer and int?

A int is a data type that stores 32 bit signed two's compliment integer. On other hand Integer is a wrapper class which wraps a primitive type int into an object. int helps in storing integer value into memory. Integer helps in converting int into object and to convert an object into int as per requirement.

What does Int 5 mean in MySQL?

In MySQL, INT(5) does not mean that values are limited to 5-character values. It only means that MySQL will try to pad these values with spaces/zeroes when returning them. The numeric range of any signed INT including INT(10), INT(5) or any other INT(n) is: -2,147,483,648 ... 2,147,483,647, which is 10 digits at most.

What is integer in MySQL?

In MySQL, INTEGER (INT) is a numeric value without a decimal. It defines whole numbers that can be stored in a field or column. In addition, MySQL supports the display_width attribute (for example, INT(1)) and the ZEROFILL attribute, which automatically adds zeros to the value depending on the display width.


2 Answers

Taken from MYSQL 5.0 online reference

The keyword INT is a synonym for INTEGER.

like image 82
TechTravelThink Avatar answered Oct 01 '22 05:10

TechTravelThink


I guess the only difference is the spelling.

So by using INT, you'd end up using less bytes on your SQL script (not that it matters).

like image 26
ksuralta Avatar answered Oct 01 '22 06:10

ksuralta