Bhushan
Bhushan

Reputation: 215

SQL query for finding tables containing a column in my schema

Can anybody tell me SQL query to return all the tables in my schema which have the column name "IS_REVIEW_APPEALS" ?

I am using Oracle database.

Thanks a lot,

Bhushan

Upvotes: 4

Views: 23556

Answers (2)

edicius6
edicius6

Reputation: 791

See below query for how to get all columns with the given name for a specific schema in Oracle:

SELECT 
    t.owner AS schema_name,
    t.table_name, 
    c.column_name
FROM sys.all_tables t 
    INNER JOIN sys.all_tab_columns c ON t.table_name = c.table_name
WHERE LOWER(t.owner) = LOWER('MySchemaNameHere')
    AND LOWER(c.column_name) LIKE LOWER('%MyColumnNameHere%')
ORDER BY t.owner, t.table_name, c.column_name;

Upvotes: 3

Justin Cave
Justin Cave

Reputation: 231661

SELECT table_name
  FROM user_tab_cols
 WHERE column_name = 'IS_REVIEW_APPEALS'

Upvotes: 11

Related Questions