Common SQL Errors

MySQL Error 1168: ER_WRONG_MRG_TABLE - Causes, Fixes, and Prevention

Galaxy Team
August 6, 2025

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.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1168 ER_WRONG_MRG_TABLE?

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.

Error Highlights

Typical Error Message

ER_WRONG_MRG_TABLE

Error Type

Table Definition Error

Language

MySQL

Symbol

Unable to open underlying table which is differently

Error Code

1168

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 1168 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.

What causes this error?

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.

How to fix MySQL Error 1168

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).

Common scenarios and solutions

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.

Best practices to avoid this error

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.

Related errors and solutions

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.

.

Common Causes

Mismatched column definitions

One or more underlying tables have different columns, data types, default values, or order compared with the MERGE table definition.

Non-MyISAM storage engine

A referenced table was converted to InnoDB, Aria, or another engine, breaking the MERGE contract that all members be MyISAM.

Missing underlying table

The UNION list includes a table that was dropped, renamed, or located in another database, so MySQL cannot open it.

Different table options

Discrepancies in ROW_FORMAT, CHARACTER SET, AUTO_INCREMENT, or PACK_KEYS between tables can be enough to cause the error.

.

Related Errors

FAQs

Can I use InnoDB with MERGE tables?

No. MERGE tables only support the MyISAM engine. Switching any member to InnoDB triggers error 1168.

Will ALTER TABLE on the MERGE table propagate to underlying tables?

No. You must run the same ALTER on every underlying table manually or via automation.

How does Galaxy help detect this error?

Galaxy’s schema diff view flags structural drift across tables, alerting you before a query reaches production and triggers error 1168.

Is MERGE deprecated in newer MySQL versions?

No, but MERGE is rarely used. Partitioned InnoDB tables offer similar benefits without the strict engine limitation.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo