This document describes how to list views in BigQuery.
You can list views in datasets by:
- Using the Cloud Console
- Using the
bq ls
command in thebq
command-line tool - Calling the
tables.list
API method - Using the client libraries
Required permissions
At a minimum, to list views in a dataset, you must be granted
bigquery.tables.list
permissions. The following predefined
IAM roles include bigquery.tables.list
permissions:
bigquery.user
bigquery.metadataViewer
bigquery.dataViewer
bigquery.dataOwner
bigquery.dataEditor
bigquery.admin
For more information on IAM roles and permissions in BigQuery, see Predefined roles and permissions.
Listing views
Listing views is identical to the process for listing tables.
To list the views in a dataset:
Console
In the Explorer panel, expand your project and select a dataset.
Scroll through the list to see the tables in the dataset. Tables and views are identified by different icons.
bq
Issue the bq ls
command. The --format
flag can be used to control the
output. If you are listing views in a project other than your default
project, add the project ID to the dataset in the following format:
project_id:dataset
.
bq ls --format=pretty project_id:dataset
Where:
- project_id is your project ID.
- dataset is the name of the dataset.
When you run the command, the Type
field displays either TABLE
or
VIEW
. For example:
+-------------------------+-------+----------------------+-------------------+ | tableId | Type | Labels | Time Partitioning | +-------------------------+-------+----------------------+-------------------+ | mytable | TABLE | department:shipping | | | myview | VIEW | | | +-------------------------+-------+----------------------+-------------------+
Examples:
Enter the following command to list views in dataset mydataset
in your
default project.
bq ls --format=pretty mydataset
Enter the following command to list views in dataset mydataset
in
myotherproject
.
bq ls --format=pretty myotherproject:mydataset
API
To list views using the API, call the tables.list
method.
Go
Before trying this sample, follow the Go setup instructions in the BigQuery Quickstart Using Client Libraries. For more information, see the BigQuery Go API reference documentation.
Python
Before trying this sample, follow the Python setup instructions in the BigQuery Quickstart Using Client Libraries. For more information, see the BigQuery Python API reference documentation.
Next steps
- For information on creating views, see Creating views.
- For information on creating an authorized view, see Creating authorized views.
- For information on getting view metadata, see Getting information about views.
- For information on updating views, see Updating views.
- For more information on managing views, see Managing views.