简体   繁体   English

在数据库的所有表、行和列中搜索已删除表的引用 id

[英]Search for a deleted table's reference id in all tables, rows and columns of a DB

I had created a table in my DB and then deleted whole table.我在我的数据库中创建了一个表,然后删除了整个表。 but now I got error of Foreign Key constraint of that table id.但现在我得到了该表ID的外键约束错误。 And due to it I am unable to update any other thing for my app in local.由于它,我无法在本地更新我的应用程序的任何其他内容。

I am having 400+ tables in my database with thousands of records.我的数据库中有 400 多个表,其中包含数千条记录。

How could I find that deleted table's reference id in my all current tables?如何在所有当前表中找到已删除表的参考 ID?

You can try to find all the referenced tables for the deleted table in the system database information_schema :您可以尝试在系统数据库information_schema中查找已删除表的所有引用表:

SELECT 
  kcu.TABLE_NAME, kcu.CONSTRAINT_NAME, kcu.COLUMN_NAME, 
  kcu.REFERENCED_TABLE_NAME, kcu.REFERENCED_COLUMN_NAME
FROM information_schema.KEY_COLUMN_USAGE kcu
WHERE kcu.REFERENCED_TABLE_SCHEMA = 'YourDatabaseName' AND 
      kcu.REFERENCED_TABLE_NAME = 'YourDeletedTableName'

You can search on the whole schema(DB) from mysql workbench for the referenced column name from there you will be able to find all the references您可以从 mysql 工作台搜索整个架构(DB),以从那里找到引用的列名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM