What is MySQL INT Data Type?
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
In MySQL, the INT data type stores integer values without decimal points, offering a fixed-point solution for whole numbers. Users define columns with this type to accommodate various numeric data within a specified range. Let’s dive further into MySQL’s INT data type!
INT?To define a column with the INT data type in MySQL, users employ the following syntax:
column_name INT[(M)] [UNSIGNED] [ZEROFILL]
M: Specifies the display width, affecting the visual representation without altering the stored range.UNSIGNED: Optionally signifies that the column accepts only non-negative values, expanding the positive range.ZEROFILL: Optionally pads the displayed value with zeros up to the defined width, commonly used with UNSIGNED.Consider this table creation example:
CREATE TABLE example_table (
id INT,
age INT UNSIGNED
);
Here, id is a signed INT column, while age is an unsigned INT column.
Storage needs for INT in MySQL differ based on its size:
INT: Occupies 4 bytes and accommodates values from -2,147,483,648 to 2,147,483,647.INT UNSIGNED: Also uses 4 bytes but allows values within 0 to 4,294,967,295.The INT data type serves various purposes, including storing counts, IDs, and other numeric data without decimal precision.
MySQL’s INT data type offers a flexible solution for storing integer values within defined ranges. Mastery of its syntax, storage considerations, and usage scenarios is crucial for effective database management and query optimization.
Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.