3220
MariaDBERRORCommonDDL / UpgradeHIGH confidence

Table needs rebuild after upgrade

Production Risk

High — table may be inaccessible without rebuild.

Why it happens
  1. 1Table was created with an older MySQL version and requires a rebuild for compatibility.
  2. 2Internal row format or index structure is outdated after a major version upgrade.
How to reproduce
trigger — this will error
trigger — this will error
SELECT * FROM old_table;

expected output

ERROR 3220 (HY000): Table needs a rebuild. Run ALTER TABLE ... FORCE.

Fix 1

Force rebuild with ALTER TABLE

Force rebuild with ALTER TABLE
ALTER TABLE old_table FORCE;

Why this works

Rebuilds the table with the current storage format and index structures.

Fix 2

Use REPAIR TABLE for MyISAM tables

Use REPAIR TABLE for MyISAM tables
REPAIR TABLE old_table;

Why this works

MyISAM tables use REPAIR TABLE rather than ALTER TABLE FORCE.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 3220 ER_TABLE_NEEDS_REBUILD

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

← All MariaDB errors