find sql table name with a particular column

前端 未结 3 569
予麋鹿
予麋鹿 2020-12-14 15:31

Is their any other way or sql query to find the database table names with a particular column than shown below,

SELECT TABLE_NAME FROM INFORMATI         


        
相关标签:
3条回答
  • 2020-12-14 16:00

    you can run this query

    SELECT t.name AS table_name,
    SCHEMA_NAME(schema_id) AS schema_name,
    c.name AS column_name
    FROM sys.tables AS t
    INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
    WHERE c.name LIKE '%Column%' -- write the column you search here
    ORDER BY schema_name, table_name;
    
    0 讨论(0)
  • 2020-12-14 16:08

    For Oracle Database. Use the below query:

    select table_name from all_tab_columns where column_name = 'NameID';
    

    If you’ve got DBA privileges, you can try this command instead:

    select table_name from dba_tab_columns where column_name = 'NameID';
    
    0 讨论(0)
  • 2020-12-14 16:16

    In SQL Server, you can query sys.columns.

    Something like:

     SELECT
         t.name
     FROM
         sys.columns c
            inner join
         sys.tables t
            on
               c.object_id = t.object_id
     WHERE
         c.name = 'NameID'
    

    You might want an additional lookup to resolve the schema name, if you have tables in multiple schemas.

    0 讨论(0)
提交回复
热议问题