Find tables with specific column name

Query below finds all tables in all databases of Teradata Database instance that have 'code' column.

Query

SELECT  TablesV.DatabaseName,
        TablesV.TableName
FROM    DBC.TablesV
INNER JOIN DBC.ColumnsV ON TablesV.DatabaseName = ColumnsV.DatabaseName
        AND TablesV.TableName = ColumnsV.TableName
WHERE   ColumnsV.ColumnName = 'code'
AND     TablesV.TableKind = 'T'
ORDER BY    TablesV.DatabaseName,
            TablesV.TableName;

Columns

  • DatabaseName - name of table's database where column was found in
  • TableName - name of found table

Rows

  • One row represents one table
  • Scope of rows: all found tables
  • Ordered by database & table name

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.