VIEWS view
TheINFORMATION_SCHEMA.VIEWS
view contains metadata about views.
Required permissions
To get view metadata, you need the following Identity and Access Management (IAM)permissions:
bigquery.tables.get
bigquery.tables.list
Each of the following predefined IAM roles includes thepermissions that you need in order to get view metadata:
roles/bigquery.admin
roles/bigquery.dataEditor
roles/bigquery.metadataViewer
roles/bigquery.dataViewer
For more information about BigQuery permissions, seeAccess control with IAM.
Schema
When you query theINFORMATION_SCHEMA.VIEWS
view, the query results containone row for each view in a dataset.
TheINFORMATION_SCHEMA.VIEWS
view has the following schema:
Column name | Data type | Value |
---|---|---|
TABLE_CATALOG | STRING | The name of the project that contains the dataset |
TABLE_SCHEMA | STRING | The name of the dataset that contains the view also referred to as the datasetid |
TABLE_NAME | STRING | The name of the view also referred to as the tableid |
VIEW_DEFINITION | STRING | The SQL query that defines the view |
CHECK_OPTION | STRING | The value returned is alwaysNULL |
USE_STANDARD_SQL | STRING | YES if the view was created by using a GoogleSQL query;NO ifuseLegacySql is set totrue |
Scope and syntax
Queries against this view must include a dataset or a region qualifier. Forqueries with a dataset qualifier, you must have permissions for the dataset.For queries with a region qualifier, you must have permissions for the project.For moreinformation seeSyntax.The following table explains the region and resource scopes for this view:
View name | Resource scope | Region scope |
---|---|---|
[PROJECT_ID.]`region-REGION`.INFORMATION_SCHEMA.VIEWS | Project level | REGION |
[PROJECT_ID.]DATASET_ID.INFORMATION_SCHEMA.VIEWS | Dataset level | Dataset location |
- Optional:
PROJECT_ID
: the ID of your Google Cloud project. If not specified, the default project is used. REGION
: anydataset region name. For example,`region-us`
.DATASET_ID
: the ID of your dataset. For more information, seeDataset qualifier.Note: You must usea region qualifier to query
INFORMATION_SCHEMA
views. The location of the query execution must match the region of theINFORMATION_SCHEMA
view.
For example:
-- Returns metadata for views in a single dataset.SELECT*FROMmyDataset.INFORMATION_SCHEMA.VIEWS;-- Returns metadata for all views in a region.SELECT*FROMregion-us.INFORMATION_SCHEMA.VIEWS;
Examples
Example 1:
The following example retrieves all columns from theINFORMATION_SCHEMA.VIEWS
view except forcheck_option
which is reserved for future use. The metadatareturned is for all views inmydataset
in your default project —myproject
.
To run the query against a project other than your default project, add theproject ID to the dataset in the following format:`project_id`.dataset.INFORMATION_SCHEMA.view
;for example,`myproject`.mydataset.INFORMATION_SCHEMA.VIEWS
.
SELECT*EXCEPT(check_option)FROMmydataset.INFORMATION_SCHEMA.VIEWS;
INFORMATION_SCHEMA
view names are case-sensitive.The result is similar to the following:
+----------------+---------------+---------------+---------------------------------------------------------------------+------------------+ | table_catalog | table_schema | table_name | view_definition | use_standard_sql | +----------------+---------------+---------------+---------------------------------------------------------------------+------------------+ | myproject | mydataset | myview | SELECT column1, column2 FROM [myproject:mydataset.mytable] LIMIT 10 | NO | +----------------+---------------+---------------+---------------------------------------------------------------------+------------------+
Note that the results show that this view was created by using a legacy SQLquery.
Example 2:
The following example retrieves the SQL query and query syntax used to definemyview
inmydataset
in your default project —myproject
.
To run the query against a project other than your default project, add theproject ID to the dataset in the following format:`project_id`.dataset.INFORMATION_SCHEMA.view
;for example,`myproject`.mydataset.INFORMATION_SCHEMA.VIEWS
.
SELECTtable_name,view_definition,use_standard_sqlFROMmydataset.INFORMATION_SCHEMA.VIEWSWHEREtable_name='myview';
INFORMATION_SCHEMA
view names are case-sensitive.The result is similar to the following:
+---------------+---------------------------------------------------------------+------------------+ | table_name | view_definition | use_standard_sql | +---------------+---------------------------------------------------------------+------------------+ | myview | SELECT column1, column2, column3 FROMmydataset.mytable
| YES | +---------------+---------------------------------------------------------------+------------------+
Note that the results show that this view was created by using aGoogleSQL query.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-02 UTC.