Get List of Tables/Views and Schema in BigQuery

visibility 3,969 access_time 2 years ago languageEnglish

BigQuery provides system views to get a list of tables and views in a certain dataset. 

__TABLES__

The following query retrieves all the tables and views in dataset named `test`:

SELECT * FROM `test`.__TABLES__;
The results looks similar to something below:
The information returned includes:
  • Project ID
  • Dataset ID
  • Object creation time
  • Last modification time
  • Record count (for tables)
  • Size in bytes (for tables)
  • Type: 1 - table; 2- View

Retrieve object schema

Sometimes it is useful to retrieve the schema information of an object in BigQuery.

There are system views can be used to retrieve metadata information.

Retrieve table and view list

SELECT * FROM test.INFORMATION_SCHEMA.TABLES

The results looks similar to the following screenshot:


Retrieve table schema

The following query returns the schema metadata of table dim_customer in dataset test.

SELECT * EXCEPT(table_catalog) FROM test.INFORMATION_SCHEMA.COLUMNS
WHERE table_name='dim_customer' AND table_schema='test';

The output shows all the columns in table test.dim_customer:


References

Getting table metadata using INFORMATION_SCHEMA  |  BigQuery (google.com)

copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

timeline Stats
Page index 9.19
More from Kontext
BigQuery SQL - COALESCE and IFNULL Functions
visibility 769
thumb_up 0
access_time 2 years ago
BigQuery: Create Partitioned Table as SELECT
visibility 1,082
thumb_up 0
access_time 2 years ago
Random Sampling in Google BigQuery
visibility 471
thumb_up 0
access_time 2 years ago