MySQL unsigned attribute
The integer type has an optional UNSIGNED attribute, which indicates that negative values are not allowed, which roughly doubles the upper limit of positive numbers.
You can use these integer types: TINYINT,SMALLINT,MEDIUMINT,INT,BIGINT. Respectively use 8pr 16pr 24pr 32 pr 64-bit storage space
The values they can store range from-2 (nmur1) to 2 (nmur1)-1, where n is the number of digits of the storage space.
As set up in the following table
Click (here) to collapse or open
CREATE TABLE `guo` (
`id`int (1) DEFAULT NULL
`qq` int (1) unsigned DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8id is not specified unsigned, and qq is specified unsigned
Insert data into the qq column first
According to the calculation, 2 (nMel 1)-1 is 2147483647.
Inserted successfully
Insert 2147483648 to indicate that it is out of range.
The unsigned column is inserted below, and the range should be
2 (nmur1) + 2 (nmur1)-1 is 4294967295
4294967296 is reported out of range.
Note that the int type definition is all int (1)
MySQL can specify a width for integers, such as int (11), which is meaningless for most applications: it does not limit the legal range of values, but simply specifies the number of characters used by some of MySQL's interactive tools, such as the MySQL command line client. For storage and computing, int (1) and int (20) are the same.