The server rejects creating an index on a virtual generated column in versions where this restriction exists.
MySQL error 3103 ER_KEY_BASED_ON_GENERATED_COLUMN occurs when you try to add a key or index to a virtual generated column in 5.7.6 and select 5.7.7 builds. Convert the column to STORED or do not index it to resolve the problem.
ER_KEY_BASED_ON_GENERATED_COLUMN
MySQL throws error 3103 when a CREATE TABLE or ALTER TABLE statement tries to place a PRIMARY KEY, UNIQUE KEY, or secondary index on a virtual generated column. The restriction was introduced in 5.7.6 and lifted shortly after 5.7.7, so only builds within that window are affected today.
The message signals that the storage engine cannot maintain an index for a column whose value is computed at read time rather than persisted on disk. Understanding the version-specific rule is critical before changing table design or upgrading a database.
The most common trigger is adding INDEX or KEY definitions on a column declared as GENERATED ALWAYS AS (...) VIRTUAL. Because virtual columns are derived on the fly, MySQL 5.7.6 refused to permit any key maintenance on them.
Another source is importing a dump created on a newer MySQL release into a 5.7.6 instance. The schema may include allowed indexes in later versions that are illegal in 5.7.6.
Convert the generated column to STORED so MySQL writes the computed value to disk, then re-add the desired key. STORED columns behave like normal columns for indexing purposes.
If the column must stay virtual, drop the attempted index and rely on indexing the underlying base columns instead.
During green-field schema design, declare generated columns as STORED whenever they need to participate in UNIQUE constraints.
When restoring a schema, upgrade the destination server to 5.7.8 or newer where indexing virtual columns is permitted.
Track server version capabilities before writing DDL. MySQL 5.7.8+ and all 8.0 versions allow indexes on virtual columns.
Use CI migrations in Galaxy to test DDL against the exact production version, catching errors earlier in development.
Error 3106 ER_WRONG_FK_COL_TYPE appears when foreign keys reference mismatched column types. Align the data types to fix.
Error 3102 ER_UNSUPPORTED_ALTER_INPLACE is thrown if an online ALTER TABLE option is impossible. Remove ALGORITHM=INPLACE or use copy-based ALTER.
A CREATE TABLE or ALTER TABLE statement explicitly declares KEY(col_virtual).
Dump contains keys on virtual columns that are only valid in later releases.
Developer assumes virtual and stored generated columns share identical indexing rules in all versions.
Raised when a generated column references an undefined column. Define referenced columns first.
Appears when attempting unsupported operations like DROP on required generated columns. Convert to regular columns before alteration.
Signals an online DDL action MySQL cannot execute in place. Remove ALGORITHM=INPLACE or use COPY.
Yes, MySQL 5.7.8 and all 8.0 releases support keys on virtual generated columns. Only 5.7.6 through 5.7.7 reject them.
STORED columns may increase write cost slightly because MySQL persists the computed value, but read queries benefit from normal index lookups.
Galaxy surfaces server error 3103 immediately in its results pane and offers AI suggestions to convert the column to STORED or drop the key.
No. Moving to 5.7.8+ keeps previously created indexes intact and lets you add new ones.