MySQL raises ER_WRONG_MRG_TABLE (error 1168) when a MERGE (MRG_MYISAM) table cannot open or map to its underlying MyISAM tables because definitions differ, the storage engine is not MyISAM, or a base table is missing.
MySQL Error 1168: ER_WRONG_MRG_TABLE occurs when a MERGE table points to underlying tables that are missing, use a non-MyISAM engine, or have mismatched column definitions. Align the definitions and ensure all referenced tables exist and use the MyISAM engine to resolve the error.
ER_WRONG_MRG_TABLE
MySQL throws error 1168 with the message “Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist” when you query or open a MERGE table whose UNION list references underlying tables that do not satisfy strict requirements.
A MERGE table (also called MRG_MYISAM) is a logical wrapper that allows you to query multiple MyISAM tables as if they were one.
Every base table must exist, be MyISAM, and have an identical structure in column order, types, default values, and indexes.
The error fires when any table listed in the UNION clause is missing, uses a different storage engine, or has a column definition or index that differs from the MERGE table definition.
Even subtle differences such as CHARSET or AUTO_INCREMENT settings can trigger the failure.
Verify that each underlying table exists, uses the MyISAM engine, and matches the exact structure of the MERGE table. Re-create tables or ALTER them until SHOW CREATE TABLE outputs are identical (except for the table name).
Scenario 1 - A base table was converted to InnoDB for transactional support and left in the UNION list.
Convert it back to MyISAM or remove it from the list.
Scenario 2 - Columns were added to one partition table but not the others. Apply the same ALTER TABLE to every table and update the MERGE definition if needed.
Automate DDL changes so every underlying table is altered in lockstep. Use tools like pt-online-schema-change on all tables in the MERGE group.
Periodically compare SHOW CREATE TABLE outputs to detect drift.
Error 1169 ER_WRONG_TYPE_FOR_JSON occurs when JSON functions operate on non-JSON columns. Error 1194 ER_CRASHED when the storage engine reports a crashed MyISAM table. Both require validating storage engine and table integrity, similar to the approach used for error 1168.
.
One or more underlying tables have different columns, data types, default values, or order compared with the MERGE table definition.
A referenced table was converted to InnoDB, Aria, or another engine, breaking the MERGE contract that all members be MyISAM.
The UNION list includes a table that was dropped, renamed, or located in another database, so MySQL cannot open it.
Discrepancies in ROW_FORMAT, CHARACTER SET, AUTO_INCREMENT, or PACK_KEYS between tables can be enough to cause the error.
.
No. MERGE tables only support the MyISAM engine. Switching any member to InnoDB triggers error 1168.
No. You must run the same ALTER on every underlying table manually or via automation.
Galaxy’s schema diff view flags structural drift across tables, alerting you before a query reaches production and triggers error 1168.
No, but MERGE is rarely used. Partitioned InnoDB tables offer similar benefits without the strict engine limitation.