如何在 MySQL 中找到包含特定列名的所有表? [英] How can I find all the tables in MySQL with specific column names in them?

查看:39
本文介绍了如何在 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数据库中包含columnAColumnB列的所有表>:

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';

这篇关于如何在 MySQL 中找到包含特定列名的所有表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆