// MySQL error reference

MySQL error 1264: Out of range value for column

A number is too large or too small for the column's type, such as 300 into TINYINT or a negative value into an UNSIGNED column.

Error number
1264
Name
ER_WARN_DATA_OUT_OF_RANGE
SQLSTATE
22003
Category
Data values
Error message
Out of range value for column '%s' at row %ld

What it means

Every numeric type has a range: TINYINT is -128 to 127 (0 to 255 unsigned), INT about ±2.1 billion, and DECIMAL(5,2) up to 999.99. A value outside it fails with 1264 in strict mode, or is clipped to the nearest limit with a warning otherwise.

Common causes

  • An INT id or counter that outgrew its type.
  • Negative values in UNSIGNED columns, sometimes from subtraction in an UPDATE.
  • A DECIMAL with too few digits before the decimal point.

How to fix it

  1. Widen the column.

    ALTER TABLE orders MODIFY id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;
    ALTER TABLE products MODIFY price DECIMAL(10,2) NOT NULL;
  2. Guard subtractions on unsigned columns.

    UPDATE stock SET qty = GREATEST(CAST(qty AS SIGNED) - 5, 0) WHERE product_id = 7;

Reproduce it safely

CREATE TEMPORARY TABLE t (n TINYINT);
INSERT INTO t VALUES (300);  -- ERROR 1264 (22003)

Related errors

More data values errors

The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.

// fewer errors, faster fixes

Work on MySQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.