如何在 MySQL 中找到包含特定列名的所有表?
我有 2-3 个不同的列名,我想在整个数据库中查找并列出所有包含这些列的表.有没有简单的脚本?
I have 2-3 different column names that I want to look up in the entire database and list out all tables which have those columns. Is there any easy script?
推荐答案
获取YourDatabase
数据库中包含columnA
或ColumnB
列的所有表>:
To get all tables with columns columnA
or ColumnB
in the database YourDatabase
:
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('columnA','ColumnB')
AND TABLE_SCHEMA='YourDatabase';
相关文章