Nir99
Nir99

Reputation: 315

Is it possible to get the columns of few tables at once?

I'm interested in getting the structure of each table in my DB. Currently I'm using: DESCRIBE TABLE table1. However, this means I have to do a separate query for each table. Was wondering whether there is a query I can get the structure of several tables at once (and therefore saving me some queries)?

Thanks, Nir.

Upvotes: 0

Views: 56

Answers (2)

Rich Murnane
Rich Murnane

Reputation: 2920

You have a couple options:

  1. you can use the COLUMNS view in the information schema

https://docs.snowflake.com/en/sql-reference/info-schema/columns.html

Note: The view only displays objects for which the current role for the session has been granted access privileges.

  1. you can use the COLUMNS view in the account_usage share schema:

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

Note: this will show all the columns in all tables, will show deleted objects and such as well. Also note, there is a delay in the data (latency could be as much as 90 minutes, typically isn't though)

Upvotes: 0

Iqra Ijaz
Iqra Ijaz

Reputation: 281

You can use Account Usage/Information Schema view COLUMNS

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

Following article have a slight difference example of using COLUMNS view to create a select statement but it should give you an idea

https://community.snowflake.com/s/article/Select-columns-based-on-condition-in-Snowflake-using-Information-Schema-and-Stored-Procedure

Upvotes: 2

Related Questions