Skip to content
MySQL

MySQL Error 1264

Out of range value for column

Applies to: MySQL 5.7, 8.0 and 8.4 (an error in strict mode, a warning without it)
Last technically reviewed 24 October 2026 on MySQL 8.0.46
The full message
ERROR 1264 (22003): Out of range value for column 'stock' at row 1
Other forms of this message
Multi-row INSERT (the row number points at the bad row)
ERROR 1264 (22003): Out of range value for column 'stock' at row 2
PHP PDO
SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'qty' at row 1
INSERT IGNORE or strict mode off (a warning; the value is clipped, for example 300 becomes 127 in a TINYINT)
Warning (Code 1264): Out of range value for column 'stock' at row 1
Error number
1264
SQLSTATE
22003
Symbol
ER_WARN_DATA_OUT_OF_RANGE
Product
MySQL Server
Versions
MySQL 5.7, 8.0 and 8.4 (an error in strict mode, a warning without it)
Last reviewed
24 October 2026

What it means

Error 1264 means a number is too large, too small or negative for the column's data type, so in strict mode MySQL rejected it instead of storing a clipped value.

Every numeric column has a fixed range. A signed TINYINT holds -128 to 127, an INT about plus or minus 2.1 billion, an UNSIGNED column nothing below 0, and DECIMAL(5,2) at most 999.99 (five digits in total, two after the point). When an INSERT, UPDATE, LOAD DATA or ALTER TABLE would store a value outside that range, strict mode stops the statement with 1264 and names the column and the row number within the statement. A value that is rounded to fit can also overflow: 999.999 rounds to 1000.00, which does not fit DECIMAL(5,2).

Without strict mode MySQL clips the value to the nearest end of the range and only warns, so 300 is stored as 127 and -5 as 0 in an UNSIGNED column. That is silent data corruption; keep strict mode on. Overflow inside an expression, such as qty - 10 on an UNSIGNED column going below zero, is error 1690 rather than 1264. See SQL data types explained for choosing column types.

Common causes

  • The column type is too small for real data: a TINYINT for stock levels, an INT for phone numbers, ids from another system or file sizes in bytes.
  • A DECIMAL has too few digits before the point, for example DECIMAL(5,2) for prices that can reach 1000 or more.
  • A negative number is written to an UNSIGNED column, often a refund, an adjustment or a bug in the calculation.
  • An UPDATE multiplies or adds to a value until it no longer fits, for example SET stock = stock * 20.
  • ALTER TABLE changes a column to a smaller type while some rows hold values that do not fit.

Diagnose it

Read-only These statements only read metadata (information_schema, performance_schema and SHOW statements) or your own data. They do not change data, privileges or configuration, so they are safe to run first.

Check the column type and precision

SELECT column_name, column_type, numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_schema = DATABASE()
  AND table_name = 'products'
ORDER BY ordinal_position;
What to look for

column_type shows the type and whether it is unsigned. For DECIMAL(p,s), the largest value has p minus s digits before the point.

Find source values that will not fit before loading them

Compare the incoming data with the target range (here SMALLINT UNSIGNED, 0 to 65535).

SELECT id, qty
FROM staging_products
WHERE qty < 0 OR qty > 65535;
What to look for

Every row that would raise 1264. Either the data is wrong or the column type is too small.

Find rows that block shrinking a column

SELECT id, total
FROM orders
WHERE total NOT BETWEEN -32768 AND 32767;  -- the SMALLINT range
What to look for

The rows that make ALTER TABLE ... MODIFY total SMALLINT fail. An empty result means the change is safe for the data.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Widen the column to a type that fits the data

Changes schema

Pick a type with room for real values: SMALLINT or INT instead of TINYINT, BIGINT for large counters and external ids, more digits for DECIMAL. Check with the data owner what the largest realistic value is.

Caution: Changing a column type rebuilds the table, which takes time and blocks writes on large tables; run it in a maintenance window and update foreign key columns that reference it to the same type.

ALTER TABLE products
  MODIFY stock INT NOT NULL DEFAULT 0,
  MODIFY price DECIMAL(10,2);

Store identifiers such as phone numbers as text

Changes schema

Phone numbers, postcodes and account numbers are labels, not quantities: they can start with 0 or +, and you never do arithmetic on them. Use VARCHAR.

Caution: Existing numeric values are converted to text as they are; leading zeros that were already lost cannot be recovered.

ALTER TABLE phones MODIFY phone VARCHAR(20);

Validate or reject the value before writing it

Client or network side

If the column range is correct and the value is wrong (a negative quantity, a typo with extra digits), validate input in the application and return a clear error. For calculations on UNSIGNED columns, check the result first, for example with WHERE stock >= 10 on the UPDATE.

Fix out-of-range rows before shrinking a column

Changes data

If you really want the smaller type, correct or archive the rows found by the diagnostic above, then run the ALTER TABLE. Otherwise keep the wider type.

Caution: Overwriting values loses the original number. Copy the affected rows to an archive table first, and prefer keeping the wider type over capping real data.

UPDATE orders SET total = 32767 WHERE id = 1;  -- only if the business agrees this value is correct
ALTER TABLE orders MODIFY total SMALLINT;

Examples

A value too large for a TINYINT

CREATE TABLE products (
    id    INT PRIMARY KEY,
    stock TINYINT  -- -128 to 127
);

INSERT INTO products (id, stock) VALUES (1, 300);
Result
ERROR 1264 (22003): Out of range value for column 'stock' at row 1

Reproduced on MySQL 8.0.46, 24 October 2026.

A price with too many digits for DECIMAL(5,2)

CREATE TABLE products (
    id    INT PRIMARY KEY,
    price DECIMAL(5,2)  -- at most 999.99
);

INSERT INTO products (id, price) VALUES (2, 1234.50);
Result
ERROR 1264 (22003): Out of range value for column 'price' at row 1

Reproduced on MySQL 8.0.46, 24 October 2026.

A phone number stored in an INT

CREATE TABLE phones (
    id    INT PRIMARY KEY,
    phone INT  -- at most 2147483647
);

INSERT INTO phones VALUES (1, 447700900123);
Result
ERROR 1264 (22003): Out of range value for column 'phone' at row 1

Reproduced on MySQL 8.0.46, 24 October 2026.

Shrinking a column that holds larger values

CREATE TABLE orders (id INT PRIMARY KEY, total INT);
INSERT INTO orders VALUES (1, 50000);

ALTER TABLE orders MODIFY total SMALLINT;  -- SMALLINT stops at 32767
Result
ERROR 1264 (22003): Out of range value for column 'total' at row 1

Reproduced on MySQL 8.0.46, 24 October 2026.

How to prevent it

Size numeric columns for the largest realistic value, not today's data: INT or BIGINT for counters and ids, DECIMAL with enough digits for money, and VARCHAR for phone numbers and other codes. Use UNSIGNED only where a negative value is truly impossible, and remember that calculations on it can still go negative.

Validate numbers at the application boundary and check staging data against the target range before loading. Keep strict mode on so an out-of-range value fails loudly instead of being clipped to the end of the range.

Common questions

How do I fix MySQL error 1264?

Compare the value with the column type named in the message. If the value is valid, widen the column (for example TINYINT to INT, or more DECIMAL digits); if the value is wrong, fix it before writing. Use VARCHAR for phone numbers and similar codes.

Why does a value like 999.999 fail in a DECIMAL(5,2) column?

MySQL rounds it to two decimal places first, giving 1000.00, which needs four digits before the point. DECIMAL(5,2) allows only three, so the rounded value is out of range.

Why did the same insert work before, with a different value stored?

Without strict mode MySQL clips an out-of-range value to the nearest end of the column range and only raises a warning, so 300 became 127 in a TINYINT. That stored value is wrong; strict mode turns it into this error.

What is the difference between error 1264 and error 1690?

1264 is raised when a value does not fit the column it is being stored in. 1690 is raised when a calculation itself overflows, for example subtracting from an UNSIGNED value so the result would be negative.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 24 October 2026; examples and diagnostics run on MySQL 8.0.46. Message templates checked against the server's error catalogue (perror) for that version.

Still stuck on a MySQL error?

Browse the full MySQL error library, or get hands-on help from an experienced SQL professional.