Found rows in the exchange table that do not match the partition definition
Production Risk
Medium — operation fails safely; no data moved until rows are corrected.
When performing ALTER TABLE ... EXCHANGE PARTITION, MySQL checks that all rows in the exchange table fall within the partition's value range. This error fires when rows are found that would not belong to the target partition.
- 1Exchange table contains rows with partition key values outside the range of the target partition.
-- Partition p0 covers id 1–1000, but exchange table contains id = 5000. ALTER TABLE orders EXCHANGE PARTITION p0 WITH TABLE staging;
expected output
ERROR 1737 (HY000): Found a row that does not match the partition.
Fix 1
Remove or move out-of-range rows from the exchange table
DELETE FROM staging WHERE id NOT BETWEEN 1 AND 1000; -- Then retry the EXCHANGE PARTITION.
Why this works
Ensuring all rows in the staging table fall within the partition boundary allows the exchange to proceed.
Fix 2
Use WITHOUT VALIDATION to skip the check (MySQL 5.7.5+)
ALTER TABLE orders EXCHANGE PARTITION p0 WITH TABLE staging WITHOUT VALIDATION;
Why this works
Skips the row validation check; use only when rows are known to be correct.
✕
MySQL 8.0 — 1737 ER_ROW_DOES_NOT_MATCH_PARTITION
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev