SQL Keywords

SQL INT3

What is SQL INT3?

INT3 is a MySQL-specific alias for the MEDIUMINT data type, a 3-byte integer that stores whole numbers between -8,388,608 and 8,388,607 (or 0 to 16,777,215 if UNSIGNED).
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL INT3: Supported: MySQL, MariaDB Not supported: PostgreSQL, SQL Server, Oracle, SQLite, Standard SQL

SQL INT3 Full Explanation

INT3 is not part of the ANSI SQL standard. It is a legacy MySQL synonym for MEDIUMINT, which occupies 3 bytes per row. Signed INT3 ranges from -8,388,608 to 8,388,607, while UNSIGNED extends the positive range to 0–16,777,215.INT3 behaves exactly like MEDIUMINT in every respect: you can specify an optional display width (e.g., INT3(6)), apply the UNSIGNED modifier for a larger positive range, and use ZEROFILL to left-pad displayed values. Beginning with MySQL 8.0, display width is ignored unless ZEROFILL is present, but the INT3 alias still parses.Because INT3 is MySQL-only, code that relies on it will not run on PostgreSQL, SQL Server, Oracle, SQLite, or even standard SQL. For portability and clarity, MySQL’s own documentation recommends using the canonical name MEDIUMINT instead of aliases such as INT3, INT4, or INT8.

SQL INT3 Syntax

column_name INT3 [ (display_width) ] [SIGNED | UNSIGNED] [ZEROFILL]

SQL INT3 Parameters

  • display_width (integer) - Optional visual width used with ZEROFILL.
  • SIGNED (keyword) - Default; allows negative values.
  • UNSIGNED (keyword) - Restricts column to non-negative values and doubles the positive range.
  • ZEROFILL (keyword) - Pads returned values with leading zeros up to display_width.

Example Queries Using SQL INT3

-- Create a table that uses INT3
CREATE TABLE orders (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    status_code INT3 UNSIGNED NOT NULL,
    rating INT3(3) ZEROFILL
);

-- Insert a sample row
INSERT INTO orders (status_code, rating) VALUES (5, 7);

-- Query the data
SELECT id, status_code, rating FROM orders;

Expected Output Using SQL INT3

  • Table is created successfully
  • One row is inserted
  • The SELECT query returns:+----+-------------+--------+| id | status_code | rating |+----+-------------+--------+| 1 | 5 | 007 |+----+-------------+--------+Notice rating is left-padded to three digits because of ZEROFILL

Use Cases with SQL INT3

  • Store medium-sized counters, IDs, or status codes that need more capacity than SMALLINT but less than INT.
  • Save storage in very large tables by using 3-byte integers instead of 4-byte INT.
  • Preserve legacy schemas that already rely on MEDIUMINT/INT3 without rewriting code.

Common Mistakes with SQL INT3

  • Assuming INT3 limits values to three digits; the “3” refers to bytes, not digits.
  • Using INT3 in non-MySQL databases where the alias is unrecognized, leading to syntax errors.
  • Forgetting to add UNSIGNED when only positive numbers are expected and then running out of range.
  • Believing the display width constrains stored values; it only affects formatting with ZEROFILL.

Related Topics

MEDIUMINT, TINYINT, SMALLINT, INT, BIGINT, SIGNED, UNSIGNED, ZEROFILL

First Introduced In

MySQL 3.23

Frequently Asked Questions

Is INT3 the same as MEDIUMINT?

Yes. In MySQL, INT3 is simply a synonym for MEDIUMINT. Both names allocate 3 bytes per row and share the same numeric range. Using MEDIUMINT is clearer to readers and recommended by MySQL’s documentation.

What numeric range does SQL INT3 support?

A signed INT3 column accepts values from -8,388,608 to 8,388,607. Adding the UNSIGNED modifier changes the range to 0–16,777,215.

Is INT3 portable across databases?

No. INT3 is unique to MySQL and MariaDB. PostgreSQL, SQL Server, Oracle, and SQLite do not recognize the alias, so queries containing INT3 will fail on those systems.

Should I choose INT3 or INT for my table?

Choose INT3 (MEDIUMINT) when you need more capacity than SMALLINT but want to save 1 byte per row compared with INT. Use INT when you need the full 32-bit range or maximum portability across databases.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!