What’s the difference in
int(11) UNSIGNED ?
An UNSIGNED type cannot be negative, but on the other hand it has twice as large a range for the positive integers. The types TINYINT, SMALLINT, MEDIUMINT,
INT and BIGINT all have signed and unsigned versions.
For INT the ranges are defined as follows:
Type Storage Min Max INT 4 -2147483648 2147483647 INT UNSIGNED 4 0 4294967295
The signed and unsigned types take the same storage space (4 bytes for INT).
See the documentation for more details.
INT goes from
UNSIGNED INT goes from
11 between the braces has no effect on the number, just how it’s displayed.
UNSIGNED means that it can hold only nonnegative values, i.e. it can’t hold for example
UNSIGNED is exactly that, its all positive (no sign) numbers. The size of bytes is the same, but if your data is never negative you can get larger positive numbers out of it. The 11 is the default of how many characters it will fetch and display. For the exact size, do a search for the DBMS you are using and the type.
All integer types can have an optional (nonstandard) attribute UNSIGNED. Unsigned type can be used to permit only nonnegative numbers in a column or when you need a larger upper numeric range for the column. For example, if an INT column is UNSIGNED, the size of the column’s range is the same but its endpoints shift from -2147483648 and 2147483647 up to 0 and 4294967295.
The unsigned one can’t hold negative numbers.
An unsigned integer can handle values from 0 to 2^(size in bits of the integer field). A signed integer can handle values from -2^(size of the integer field-1) to 2^(size of the integer field-1)-1.