version
remains 1
. This version number refers to the IAM policy schema version, not the version of the policy. The value for etag
is the policy version number.Call tables.setIamPolicy
to write the updated policy. Note: Empty bindings with no members are not allowed and result in an error.
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. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. IAM().SetPolicy()
function to save changes to the access policy for a table or view.
Before trying this sample, follow the Java setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Java API reference documentation. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Before trying this sample, follow the Node.js setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Node.js API reference documentation. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. Table#getIamPolicy()
function to retrieve the current IAM policy for a table or view, modify the policy by adding new bindings, and then use Table#setIamPolicy()
function to save changes to the access policy.
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. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. client.set_iam_policy()
function to save changes to the access policy for a table or view.
The following sections describe how to revoke access to different resources.
Select one of the following options:
Go to the BigQuery page.
In the Explorer panel, expand your project and select a dataset.
In the details panel, click Sharing > Permissions.
In the Dataset Permissions dialog, expand the principal whose access you want to revoke.
Click
Remove principal.In the Remove role from principal? dialog, click Remove.
To return to dataset details, click Close.
To remove access to datasets from principals, use the REVOKE
DCL statement:
In the Google Cloud console, go to the BigQuery Studio page.
In the query editor, enter the following statement:
REVOKE`ROLE_LIST`ONSCHEMARESOURCE_NAMEFROM"USER_LIST"
Replace the following:
ROLE_LIST
: a role or list of comma-separated roles that you want to revokeRESOURCE_NAME
: the name of the resource that you want to revoke permission onUSER_LIST
: a comma-separated list of users who will have their roles revoked
For a list of valid formats, see user_list
.
Click
Run.For more information about how to run queries, see Run an interactive query.
The following example revokes the Admin role on the dataset myDataset
:
REVOKE`roles/bigquery.admin`ONSCHEMA`myProject`.myDatasetFROM"group:example-team@example-pet-store.com","serviceAccount:user@test-project.iam.gserviceaccount.com"
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
To write the existing dataset information (including access controls) to a JSON file, use the bq show
command:
bqshow\--format=prettyjson\PROJECT_ID:DATASET>PATH_TO_FILE
Replace the following:
Make changes to the access
section of the JSON file. You can remove any of the specialGroup
entries: projectOwners
, projectWriters
, projectReaders
, and allAuthenticatedUsers
. You can also remove any of the following: userByEmail
, groupByEmail
, and domain
.
For example, the access
section of a dataset's JSON file would look like the following:
{"access":[{"role":"READER","specialGroup":"projectReaders"},{"role":"WRITER","specialGroup":"projectWriters"},{"role":"OWNER","specialGroup":"projectOwners"},{"role":"READER","specialGroup":"allAuthenticatedUsers"},{"role":"READER","domain":"domain_name"},{"role":"WRITER","userByEmail":"user_email"},{"role":"READER","groupByEmail":"group_email"}],...}
When your edits are complete, use the bq update
command and include the JSON file using the --source
flag. If the dataset is in a project other than your default project, add the project ID to the dataset name in the following format: PROJECT_ID:DATASET
.
bqupdate\--sourcePATH_TO_FILE\PROJECT_ID:DATASET
To verify your access control changes, use the show
command again without writing the information to a file:
bqshow--format=prettyjsonPROJECT_ID:DATASET
Call datasets.patch
and use the access
property in the Dataset
resource to update your access controls.
Because the datasets.update
method replaces the entire dataset resource, datasets.patch
is the preferred method for updating access controls.
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. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. DatasetMetadataToUpdate
type . Then call the dataset.Update()
function to update the property.
Before trying this sample, follow the Java setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Java API reference documentation. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Before trying this sample, follow the Node.js setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Node.js API reference documentation. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. Dataset#get()
method to retrieve the current metadata. Modify the access property to exclude the desired entity, and then call the Dataset#setMetadata()
function to apply the updated access list.
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. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. dataset.access_entries
property with the access controls for a dataset. Then call the client.update_dataset()
function to update the property.
Select one of the following options:
Go to the BigQuery page.
In the Explorer panel, expand your project and select a table or view.
In the details panel, click Share.
In the Share dialog, expand the principal whose access you want to revoke.
Click
Delete.In the Remove role from principal? dialog, click Remove.
To return to the table or view details, click Close.
To remove access to tables or views from principals, use the REVOKE
DCL statement:
In the Google Cloud console, go to the BigQuery Studio page.
In the query editor, enter the following statement:
REVOKE`ROLE_LIST`ONRESOURCE_TYPERESOURCE_NAMEFROM"USER_LIST"
Replace the following:
ROLE_LIST
: a role or list of comma-separated roles that you want to revokeRESOURCE_TYPE
: the type of resource that the role is revoked from
Supported values include TABLE
, VIEW
, MATERIALIZED VIEW
and EXTERNAL TABLE
.
RESOURCE_NAME
: the name of the resource that you want to revoke permission onUSER_LIST
: a comma-separated list of users who will have their roles revoked
For a list of valid formats, see user_list
.
Click
Run.For more information about how to run queries, see Run an interactive query.
The following example revokes the Admin role on the table myTable
:
REVOKE`roles/bigquery.admin`ONTABLE`myProject`.myDataset.myTableFROM"group:example-team@example-pet-store.com","serviceAccount:user@test-project.iam.gserviceaccount.com"
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
To revoke access to a table or view, use the bq remove-iam-policy-binding
command:
bqremove-iam-policy-binding--member=MEMBER_TYPE:MEMBER--role=ROLE--table=trueRESOURCE
Replace the following:
user
, group
, serviceAccount
, or domain
.tables.getIamPolicy
method.Edit the policy to remove members or bindings, or both. For the format required for the policy, see the Policy reference topic.
Call tables.setIamPolicy
to write the updated policy. Note: Empty bindings with no members are not allowed and result in an error.
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. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. policy.Remove()
function to remove the access. Then call the IAM().SetPolicy()
function to save changes to the access policy for a table or view.
Before trying this sample, follow the Java setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Java API reference documentation. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Before trying this sample, follow the Node.js setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Node.js API reference documentation. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. Table#getIamPolicy()
method. Modify the policy to remove the desired role or principal, and then apply the updated policy using the Table#setIamPolicy()
method.
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. To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries. client.set_iam_policy()
function to save changes to the access policy for a table or view.
IAM deny policies let you set guardrails on access to BigQuery resources. You can define deny rules that prevent selected principals from using certain permissions, regardless of the roles they're granted.
For information about how to create, update, and delete deny policies, see Deny access to resources.
Consider the following scenarios when you create IAM deny policies on a few BigQuery permissions:
Access to authorized resources (views, routines, datasets, or stored procedures) lets you create, drop, or manipulate a table, along with reading and modifying table data, even if you don't have direct permission to perform those operations. It can also get model data or metadata and invoke other stored procedures on the underlying table. This capability implies that the authorized resources have the following permissions:
bigquery.tables.get
bigquery.tables.list
bigquery.tables.getData
bigquery.tables.updateData
bigquery.tables.create
bigquery.tables.delete
bigquery.routines.get
bigquery.routines.list
bigquery.datasets.get
bigquery.models.getData
bigquery.models.getMetadata
To deny access to these authorized resources, add one of the following values to the deniedPrincipal
field when you create the deny policy:
Value | Use case |
---|---|
principalSet://goog/public:all | Blocks all principals including authorized resources. |
principalSet://bigquery.googleapis.com/projects/PROJECT_NUMBER/* | Blocks all BigQuery authorized resources in the specified project. PROJECT_NUMBER is an automatically generated unique identifier for your project of type INT64 . |
To exempt certain principals from the deny policy, specify those principals in the exceptionPrincipals
field of your deny policy. For example, exceptionPrincipals: "principalSet://bigquery.googleapis.com/projects/1234/*"
.
BigQuery caches query results of a job owner for 24 hours, which the job owner can access without needing the bigquery.tables.getData
permission on the table containing the data. Hence, adding an IAM deny policy to the bigquery.tables.getData
permission doesn't block access to cached results for the job owner until the cache expires. To block the job owner access to cached results, create a separate deny policy on the bigquery.jobs.create
permission.
To prevent unintended data access when using deny policies to block data read operations, we recommend that you also review and revoke any existing subscriptions on the dataset.
To create a IAM deny policy for viewing dataset access controls, deny the following permissions:
bigquery.datasets.get
bigquery.datasets.getIamPolicy
To create a IAM deny policy for updating dataset access controls, deny the following permissions:
bigquery.datasets.update
bigquery.datasets.setIamPolicy
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-25 UTC.