<p>MySQL throws error 1647 (WARN_COND_ITEM_TRUNCATED) when a CHECK constraint, trigger, or WHERE condition truncates a value during evaluation.</p>
<p>MySQL Error 1647: WARN_COND_ITEM_TRUNCATED appears when a value is silently shortened while MySQL evaluates a CHECK constraint or conditional expression. Align data types, expand column sizes, or cast inputs to remove the truncation and the error.</p>
Data truncated for condition item '%s'
MySQL raises error 1647 with the condition name WARN_COND_ITEM_TRUNCATED when a value involved in a conditional expression is implicitly shortened to fit a column or variable. Because truncation can hide logic flaws, the server stops the statement and surfaces the error.
The message usually reads Data truncated for condition item '%s', where %s is the column or expression that lost precision. Fixing the underlying type mismatch or casting the value eliminates the warning and lets the statement finish.
Implicit conversions inside CHECK constraints, triggers, or stored program conditions frequently trigger the warning. When MySQL needs to trim characters or digits to match a declared length, it flags the problem.
Length mismatch between a literal and a fixed-length CHAR, VARCHAR, or DECIMAL target is the second common cause. The issue surfaces as soon as the condition executes, even if the data would have been valid after insertion.
First identify the offending column from the error message. Compare the data type of the literal or variable used in the condition to the column definition. Adjust the condition to cast or convert the value explicitly.
If the application truly needs longer values, alter the column length or precision. After schema alignment, rerun the statement to confirm the warning no longer appears.
Inserting text into a CHECK that compares a VARCHAR(30) column against a 40-character literal will fail. Shorten the literal or widen the column.
Triggers that write DECIMAL(5,2) values from DECIMAL(7,2) expressions cause truncation. Cast the expression to DECIMAL(5,2) inside the trigger or enlarge the target column.
Always match literal lengths to column definitions when writing constraints. Use the CHAR_LENGTH function to validate strings before comparing them.
Adopt Galaxy’s schema-aware AI copilot to autocomplete columns with correct lengths and suggest safe casts. The editor highlights mismatched types during query composition, preventing truncation errors before execution.
Error 1265 Data truncated for column arises during INSERT or UPDATE rather than condition evaluation. Fix it by expanding the column or trimming input.
Error 1406 Data too long for column appears when truncation is disallowed. Increase the column size or shorten input to resolve it.
String or numeric literals exceed the column size inside a CHECK, causing MySQL to trim the value.
Triggers compare or assign values of differing precision, leading to silent truncation.
Functions such as CONCAT produce longer results than the target type, forcing a cut-off during evaluation.
Expressions write higher-precision DECIMAL values into lower-precision columns without explicit rounding.
Occurs during data modification instead of condition evaluation. Similar fix: match column sizes.
Raised when SQL_MODE is strict and truncation is disallowed. Adjust column or input length.
Triggered by character set mismatches rather than length limits. Convert encodings or collations.
Blocking prevents hidden logic errors that could let invalid data pass through constraints or triggers.
Strict modes can turn the warning into an error, but truncation inside conditions is flagged regardless of mode.
Ignoring risks logical bugs. Always align data types instead of suppressing the warning.
Galaxy’s AI copilot highlights type mismatches in real time, suggesting safe casts and preventing truncation errors.