Error
Error Code: 3192

MySQL Error 3192: FK on Base of Stored Column

📦 MySQL
📋

Description

This error occurs when you attempt to create a foreign key constraint on a column that is designated as a 'base column' for a `STORED` generated column within the same table. MySQL does not permit foreign keys to be defined on such base columns to maintain data integrity and consistency with the stored values.
💬

Error Message

Cannot add foreign key on the base column of stored column.
🔍

Known Causes

3 known causes
⚠️
Direct FK on Stored Column Base
You explicitly tried to add a foreign key constraint on a column that is used in the expression of a `STORED` generated column.
⚠️
Schema Conflict during Migration
An existing schema or a migration script attempts to define a foreign key on a column that is already a base for a `STORED` generated column.
⚠️
Misunderstanding Generated Column Types
Confusion between `STORED` generated columns (which have this restriction) and `VIRTUAL` generated columns (whose base columns can have foreign keys).
🛠️

Solutions

Coming Soon

Detailed step-by-step solutions for this error are being prepared. In the meantime, try these general troubleshooting tips:

General Troubleshooting Tips

  • Check the error message carefully for specific details
  • Review recent changes that might have caused the error
  • Search for the exact error code in the official documentation
  • Check log files for additional context
  • Try restarting the application or service
🔗

Related Errors

5 related errors