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

查看:72
本文介绍了如何在MySQL中找到所有带有特定列名的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在整个数据库中查找2-3个不同的列名称,并列出所有包含这些列的表.有简单的脚本吗?

I have 2-3 different column names that I want to look up in the entire DB and list out all tables which have those columns. 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天全站免登陆