1639
MySQLERRORCommonData IntegrityHIGH confidence
Value is out of range for column type
Production Risk
High — data may be silently corrupted in non-strict mode.
What this means
A numeric value to be stored in a column exceeds the valid range for that column data type.
Why it happens
- 1Inserting a value greater than the maximum for the column type (e.g., 200 into a TINYINT that holds -128 to 127).
- 2Arithmetic overflow in a stored expression.
How to reproduce
trigger — this will error
trigger — this will error
INSERT INTO t (tiny_col) VALUES (300); -- TINYINT max is 127 (signed)
expected output
ERROR 1639 (22003): Out of range value for column 'tiny_col' at row 1
Fix 1
Use a larger data type
Use a larger data type
ALTER TABLE t MODIFY tiny_col SMALLINT;
Why this works
A wider type accommodates larger values without truncation.
Fix 2
Validate values before INSERT
Validate values before INSERT
-- Check value < 128 before inserting into TINYINT column
Why this works
Application-level validation prevents out-of-range values reaching the database.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1639 ER_DATA_OUT_OF_RANGE
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev