📅  最后修改于: 2023-12-03 15:17:45.879000             🧑  作者: Mango
MySQL INT is a data type in MySQL used to store integer values. It can store signed or unsigned integers of different sizes. INT is a commonly used data type in MySQL and is used to store integer values in tables.
INT[(M)] [UNSIGNED] [ZEROFILL]
Where:
M
: Specifies the maximum display width for the integer. Default is 11.UNSIGNED
: Specifies that the integer should be unsigned. ZEROFILL
: Add leading zeros to the integer value.To create a table with an INT column, use the following syntax:
CREATE TABLE table_name (
col_name INT
);
You can specify the size of the INT column using the M
parameter.
CREATE TABLE table_name (
col_name INT(10)
);
You can specify that an INT column should be unsigned using the UNSIGNED
keyword.
CREATE TABLE table_name (
col_name INT UNSIGNED
);
You can use the ZEROFILL
keyword to add leading zeros to the integer value.
CREATE TABLE table_name (
col_name INT UNSIGNED ZEROFILL
);
MySQL INT is a common data type used to store integer values. It can store both signed and unsigned integers of different sizes. When creating tables, you can specify the size, whether it should be unsigned, and whether it should have leading zeros. Use the examples provided to help you create your own tables with INT columns.