MySQL INT, TINYINT, SMALLINT, MEDIUMINT, BIGINT (integer type)

Also known integer type numerical data, numeric data type is mainly used to store digital.

 

MySQL provides a variety of numeric data types, different data types with different ranges, larger range of values ​​can be stored, the storage space required will be greater.

Type Integer provided with a main MySQL  TINYINT , SMALLINT , MEDIUMINT , the INT , BIGINT , which can add attributes AUTO_INCREMENT field increment constraint. The following table lists the numeric types MySQL.

type name Explanation Storage requirements
TINYINT Small integer 1 byte
SMALLINT Small integer 2 Yu Festival
MEDIUMINT Integer medium-sized 3 byte
INT (INTEGHR) Integer normal size 4 bytes
BIGINT Large integer 8 bytes

Can be seen from the above table, the integer number of bytes required to store different types are not the same, the minimum number of bytes is occupied TINYINT type, is occupied by the maximum byte type BIGINT take up more bytes of type the larger the numerical ranges can be expressed.

It can be determined according to the number of bytes occupied by each type of data value range. For example, TINYINT requiring 1 byte (8bit) to store, then the maximum unsigned TINYINT is 28-1, i.e., 255; TINYINT have the maximum number of symbols 27-1, i.e., 127. An integer in the range of other types of the same calculation method, as shown in the following table.

type name

Guess you like

Origin blog.csdn.net/mysqlsd/article/details/103652945