How to Fix MySQL Error 3106 (ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN)
You get mysql error 3106 when a query tries an illegal action on a generated column. Fix it by changing the base columns instead of writing to the generated column. MySQL logs this failure under the symbol ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN and SQLSTATE HY000. The engine returns a clear message stating that your action is not supported for generated columns. Understanding how the database calculates these fields helps your team prevent broken writes and failed migrations. What causes m
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get mysql error 3106 when a query tries an illegal action on a generated column. Fix it by changing the base columns instead of writing to the generated column.
MySQL logs this failure under the symbol ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN and SQLSTATE HY000. The engine returns a clear message stating that your action is not supported for generated columns. Understanding how the database calculates these fields helps your team prevent broken writes and failed migrations.
What causes mysql error 3106 in your database
A generated column computes its value from an expression built on other columns in the table. Because the database engine controls this value, users and apps cannot edit it by hand. When a script or app tries a forbidden change, the engine stops the run right away.
Several common table actions trigger this specific error code in production. Trying to insert or update a specific value inside a generated column causes an immediate failure. Adding an auto-increment rule to a generated field also breaks the query. You will also hit this block if you use a generated field as a foreign key target.
Also, some schema changes trigger this exact error during deploys. For example, dropping a base column that feeds a generated expression is not allowed. Object-relational mappers often cause this bug when they build insert statements that include every table column.
How to diagnose and fix the failure in production
Start by reading the exact error message in your app log or database log. The message names the specific action that failed on the generated column. Next, inspect the table schema to see which columns use generated expressions. Check whether the column is virtual or stored, and note all base columns it reads.
If an insert or update statement caused the error, remove the generated column from the query. Or, pass the default keyword if your SQL tool requires all column in the list. Update the base columns instead, and let MySQL calculate the new result on its own. If an app framework sends the bad write, mark that field as read-only in your model.
Customer Support Access to Production + Single Sign-On (SSO): architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
When a schema migration fails with this code, check your foreign key and index rules. Move foreign key actions like cascade updates to the base columns rather than the computed field. Always test schema edits in a staging setup before running them on live tables. Never grant wide admin roles to app users just to work around a failed migration.
Preventing schema errors during team database sessions
Many generated column errors happen when engineers run manual data fixes or ad-hoc schema changes. A quick manual update can fail if the engineer forgets which columns are computed. Worse, hasty edits on base columns can change computed results across millions of rows.
To keep live data safe, limit direct write permissions on production tables. Require peer review for any query that alters table structures or modifies core data. Also, mask sensitive fields like emails, phone numbers, card numbers, and national IDs in query results. Masking rewrites matched fields in results while engineers inspect table definitions and debug broken queries.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
Can I insert data directly into a MySQL generated column?
No, you cannot insert custom values into a virtual or stored generated column. You must omit the column from your insert list or specify the default keyword.
Why does my ORM trigger ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN on save?
Many database frameworks include every model attribute when they build insert or update statements. Mark the generated column as read-only or computed in your model settings to stop this.
Can I use a generated column in a foreign key rule?
MySQL blocks foreign key actions that try to modify a generated column, such as cascade updates. Place your foreign key rules on standard base columns to avoid error 3106.
Related guides
In this post