In MySQL, INT stands for the numbers that's a entirety number. An numbers can be composed without a fragmentary component e.g., 1, 100, 4, -10, and it cannot be 1.2, 5/3, etc.
An numbers can be zero, positive, and negative. MySQL bolsters all standard SQL numbers sorts Numbers or INT and SMALLINT. In expansion, MySQL gives TINYINT MEDIUMINT, and BIGINT as expansions to the SQL standard. MySQL INT information sort can be marked and unsigned.
The taking after table outlines the characteristics of each numbers sort counting capacity in bytes, least esteem, and most extreme esteem.
Type |
Storage |
Minimum Value |
Maximum Value |
(Bytes) |
(Signed/Unsigned) |
(Signed/Unsigned) |
|
TINYINT |
1 |
-128 |
127 |
0 |
255 |
||
SMALLINT |
2 |
-32768 |
32767 |
0 |
65535 |
||
MEDIUMINT |
3 |
-8388608 |
8388607 |
0 |
16777215 |
||
INT |
4 |
-2147483648 |
2147483647 |
0 |
4294967295 |
||
BIGINT |
8 |
-9223372036854775808 |
9223372036854775807 |
0 |
18446744073709551615 |
MySQL INT with the show width attribute MySQL gives an expansion that permits you to indicate the show width alongside the INT datatype. The show width is wrapped interior brackets taking after the INT catchphrase e.g., INT(5) indicates an INT with the show width of five digits.
It is vital to note that the show width property does not control the esteem ranges that the column can store. The show width trait is regularly utilized by the applications to arrange the numbers values. MySQL incorporates the show width trait as the metadata of the returned result set.
MySQL INT with the ZEROFILL attribute in expansion to the show width trait, MySQL gives a non-standard ZEROFILL quality. In this case, MySQL replaces spaces with zero. Consider the taking after illustration.
Example :
CREATE TABLE products ( product_id INT AUTO_INCREMENT PRIMARY KEY, product_text VARCHAR(255) );
First, create a table named zerofill_test
:
CREATE TABLE zerofill_test(
id INT AUTO_INCREMENT PRIMARY KEY,
v1 INT(2) ZEROFILL,
v2 INT(3) ZEROFILL,
v3 INT(5) ZEROFILL
);
Second, insert a new row into the zerofill_test
table.
INSERT INTO zerofill_test(v1,v2,v3)
VALUES(1,6,9);
Required fields are marked *
Get all latest content delivered to your email free.