Listing views
This document describes how to list views in BigQuery.
You can list views in datasets by:
- Using the console
- Using the
bq ls
command in thebq
command-line tool - Calling the
tables.list
API method - Using the client libraries
Before you begin
Grant Identity and Access Management (IAM) roles that give users the necessary permissions to perform each task in this document.
Required permissions
To list views in a dataset, you need the bigquery.tables.list
IAM permission.
Each of the following predefined IAM roles includes the permissions that you need in order to list views in a dataset:
roles/bigquery.user
roles/bigquery.metadataViewer
roles/bigquery.dataViewer
roles/bigquery.dataOwner
roles/bigquery.dataEditor
roles/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.
View security
To control access to views in BigQuery, see Controlling access to views.
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.