Common SQL Errors

MySQL Error 3178 ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN: How to Fix and Prevent

Galaxy Team
August 8, 2025

MySQL cannot run an ONLINE ALTER TABLE that adds a virtual column with a concurrent index change.

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 ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN?

ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN occurs when MySQL 5.7.11+ tries to execute ALTER TABLE ... ADD COLUMN ... VIRTUAL with other ONLINE changes. Disable ONLINE, split the statement, or create the index after the column is added to resolve the error.

Error Highlights

Typical Error Message

ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN

Error Type

DDL Error

Language

MySQL

Symbol

ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN was added in 5.7.11.

Error Code

3178

SQL State

HY000

Explanation

Table of Contents

What is MySQL error ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN?

MySQL raises ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN when an ALTER TABLE statement marked ONLINE attempts to add a virtual column together with a concurrent index or other metadata change. The storage engine cannot keep the table online while recalculating virtual column values.

The error was introduced in MySQL 5.7.11 to protect data consistency. Understanding why it fires helps avoid disruptive schema migrations and downtime.

What Causes This Error?

The primary trigger is combining ADD COLUMN ... VIRTUAL with ADD INDEX or other ONLINE clauses in a single ALTER TABLE statement.

The server blocks the request because generating the virtual column on existing rows and building an index simultaneously would require a table copy or lock, breaking ONLINE guarantees.

How to Fix ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN

Remove the ONLINE keyword or split the operation into two steps. First, add the virtual column, then create the index in a separate ALTER TABLE.

Alternatively, convert the virtual column to a stored column or run the change during a maintenance window when table locking is acceptable.

Common Scenarios and Solutions

When adding JSON generated columns, developers often specify ONLINE to avoid downtime. MySQL rejects the statement if an index is also created. Splitting the statement keeps availability while allowing proper indexing.

CI/CD pipelines that auto append ONLINE to every ALTER TABLE may trigger this error on virtual columns. Update migration scripts to detect and adjust for virtual column alterations.

Best Practices to Avoid This Error

Plan schema changes in incremental steps. Test migrations in a staging database running the same MySQL version.

Use feature flags in tools like Galaxy to toggle ONLINE mode only when supported. Monitor ALTER TABLE logs and set alerts for error 3178 to react quickly.

Related Errors and Solutions

ER_ALTER_OPERATION_NOT_SUPPORTED: Raised when ALTER TABLE includes unsupported combinations, fix by splitting actions.

ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED: Appears when an invalid function is used in a virtual column definition, correct the expression.

Common Causes

Unsupported ONLINE with virtual column

MySQL 5.7+ cannot keep the table online while adding a virtual column because values must be derived for all existing rows.

Combined index creation

Creating an index in the same statement forces additional metadata changes, violating ONLINE constraints.

Automated migration tools

Tooling that blindly appends ONLINE to every ALTER TABLE may create conflicting clauses with virtual columns.

Related Errors

ER_ALTER_OPERATION_NOT_SUPPORTED

General error for unsupported ALTER TABLE combinations. Split operations to resolve.

ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED

Raised when a prohibited function is used in a virtual column expression. Replace with permitted functions.

ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN

Occurs when an action targets a generated column in an unsupported way, such as dropping a base column. Review documentation before altering.

FAQs

Can I ever use ONLINE with a virtual column?

Yes, if you only add or drop the virtual column without other changes. Combining it with index creation is what triggers error 3178.

Will converting the column to STORED fix the error?

Changing VIRTUAL to STORED allows ONLINE because the column is materialized and no value recalculation is needed on the fly.

Does this error appear in MySQL 8.0?

Yes. MySQL 8.0 keeps the same restriction. Follow the same split-statement workaround.

How does Galaxy help avoid this error?

Galaxy flags unsupported ONLINE clauses during linting and suggests splitting migrations, reducing production errors.

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