I want to show all tables that have specified column name

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

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

相关标签:
8条回答
  • 2020-12-13 00:29

    You can use the information schema views:

    SELECT DISTINCT TABLE_SCHEMA, TABLE_NAME
    FROM Information_Schema.Columns
    WHERE COLUMN_NAME = 'ID'
    

    Here's the MSDN reference for the "Columns" view: http://msdn.microsoft.com/en-us/library/ms188348.aspx

    0 讨论(0)
  • 2020-12-13 00:30

    If you're trying to query an Oracle database, you might want to use

    select owner, table_name 
    from all_tab_columns
    where column_name = 'ColName';
    
    0 讨论(0)
提交回复
热议问题