I want to show all tables that have specified column name

前端 未结 8 2443
粉色の甜心
粉色の甜心 2020-12-12 23:49

How can I get a list of all the tables that have a specific column name?

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 00:25

    SELECT      T.TABLE_NAME, C.COLUMN_NAME
    FROM        INFORMATION_SCHEMA.COLUMNS C
                INNER JOIN INFORMATION_SCHEMA.TABLES T ON T.TABLE_NAME = C.TABLE_NAME
    WHERE       TABLE_TYPE = 'BASE TABLE'
                AND COLUMN_NAME = 'ColName'
    

    This returns tables only and ignores views for anyone who is interested!

提交回复
热议问题