1264
MariaDBWARNINGNotableData TruncationHIGH confidence

Out of range value for column

What this means

Error/warning 1264 (SQLSTATE 22003) is issued when a value being inserted or updated exceeds the valid range for the column's declared data type. In strict SQL mode this is an error that aborts the statement. In non-strict mode it is a warning and the out-of-range value is silently truncated to the column's maximum or minimum value.

Why it happens
  1. 1Inserting a value larger than TINYINT UNSIGNED (255) or INT (2147483647) etc.
  2. 2Inserting a negative value into an UNSIGNED integer column
  3. 3Arithmetic overflow in a computed column value
How to reproduce

A value exceeding TINYINT UNSIGNED range is inserted with strict mode on.

trigger — this will error
trigger — this will error
SET sql_mode = 'STRICT_TRANS_TABLES';
CREATE TABLE config (id INT PRIMARY KEY, score TINYINT UNSIGNED);
INSERT INTO config VALUES (1, 300);  -- TINYINT UNSIGNED max is 255

expected output

ERROR 1264 (22003): Out of range value for column 'score' at row 1

Fix

Use an appropriate column data type for the expected value range

WHEN When the column type is too small for the actual data.

Use an appropriate column data type for the expected value range
ALTER TABLE config MODIFY score SMALLINT UNSIGNED;  -- max 65535
-- or:
ALTER TABLE config MODIFY score INT UNSIGNED;       -- max 4294967295

Why this works

Choosing a data type whose range encompasses the actual data values eliminates the overflow. Review the MariaDB integer type range table to pick the smallest type that fits the expected maximum value.

What not to do

Disable strict mode so values are silently clamped

Non-strict mode silently truncates 300 to 255 without an error. The stored value is wrong and there is no indication in the application that the data was changed.

Version notes
MariaDB 10.2+

STRICT_TRANS_TABLES is enabled by default in sql_mode. Behaviour differs from older MySQL 5.x defaults where non-strict was common.

Sources
Official documentation ↗

MariaDB Server error code 1264 / ER_WARN_DATA_OUT_OF_RANGE

MariaDB integer types

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors