MySQL Error number: 3193; Symbol: ER_TABLE_REFERENCED; SQLSTATE: HY000 报错 故障修复 远程处理

文档解释

Error number: 3193; Symbol: ER_TABLE_REFERENCED; SQLSTATE: HY000

Message: Cannot complete the operation because table is referenced by another connection.

Error 3193 (ER_TABLE_REFERENCED): Table ‘%s’ is being referenced and can’t be dropped

Error 3193 occurs when MySQL is trying to delete a table that has another table pointing to it. The server won’t be able to complete the request because the referenced table can’t be dropped. This prevents unintentional data loss.

Common cases involving this error involve scenarios like:

Trying to drop a table that is mentioned in a view

Trying to drop a table mentioned in a stored procedure

Trying to drop a table used in a foreign key constraint with the RESTRICT option

The solution to this error is to track down any references to the table in question and remove them before attempting to drop the table. You’ll need to perform a query to find any references that might be pointing to the table:

SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE table_name = ‘table_name_you_are_trying_to_drop’;

This query will return any tables that are pointing to the table you’re trying to drop. Once you have identified the references, you can either remove the references or drop the referenced tables before dropping the original table.

Note that if you are using the CASCADE clause on the DROP TABLE command, this should take care of any references to the dropped table.


数据运维技术 » MySQL Error number: 3193; Symbol: ER_TABLE_REFERENCED; SQLSTATE: HY000 报错 故障修复 远程处理