Harshi
Harshi

Reputation: 189

Any equivalent for DBC.TABLES and DBC.COLUMNS of Teradata in Snowflake?

In Teradata we right now have a query which gives the list of table names and column names for specific databases like:

select * from dbc.tables where databasename in ('A','B','C')

Is there an equivalent for this Snowflake?

Upvotes: 0

Views: 1002

Answers (3)

Lukasz Szozda
Lukasz Szozda

Reputation: 175706

The closest equivalent of:

select * from dbc.tables where databasename in ('A','B','C')

is:

SELECT * 
FROM SNOWFLAKE.ACCOUNT_USAGE.COLUMNS
WHERE DELETED IS NULL
  AND TABLE_CATALOG IN ('A', 'B', 'C')

Account_usage contains dropped objects so to get only current one filter condition DELETED IS NULL was added.

It is also worth noting that ACCOUNT_USAGE views have latency (for columns and tables up to 90 minutes).

Upvotes: 0

Eric Lin
Eric Lin

Reputation: 1510

INFORMATION_SCHEMA is under each database, if you want to get tables across multiple databases, then you can use

ACCOUNT_USAGE.TABLES ACCOUNT_USAGE.COLUMS

https://docs.snowflake.com/en/sql-reference/account-usage/tables.html https://docs.snowflake.com/en/sql-reference/account-usage/columns.html

Upvotes: 1

Related Questions