Restrict a table

Keep a principal, or a kind of principal, away from a table that a broad grant would otherwise reach.

Restrict a table

Pick the narrowest tool that covers who must be kept out:

WhoUseApplies to
One principal or groupAn exception on their grantThat grant only
Everyone holding a roleA deny in the custom role (create a custom role)Every grant of the role
Every principal of a kind, or every request matching a conditionA forbid policy (conditions and policies)The whole account, over any grant

An exception or a role's deny narrows only the grants it is part of: a principal who reaches the table through another grant, directly or through a group, still has that grant's access. Use Explain access to find every grant that allows it, or a forbid policy to block it whatever the grants.

Denying table.read on a table keeps a query from reading it, including through its columns. Deny table.write to stop ingestion into it.

Steps: exception on one grant

  1. Open Settings → Account → Access, or the user's page under Settings → Account → Users.
  2. On the grant that reaches the table, select Edit condition and exceptions.
  3. Open Advanced: exceptions and select Add deny.
  4. Under Denied permissions, choose the table permissions to remove, such as table.read.
  5. Under Condition, name the tables: resource.Name == "payroll", or resource.Name in ["payroll", "salaries"].
  6. Select Save.

A grant holds at most 16 exceptions. An exception can only remove permissions the role grants.

Example: keep a service account out of hr.* tables

A service account holds Data reader on the account for an alert.

  1. Open Settings → Account → Service accounts, select it, and under Roles held select Edit condition and exceptions on its Data reader grant.
  2. Add deny: Denied permissions table.read, Condition resource.Name.startsWith("hr.").
  3. Save, then confirm with Explain access: subject the service account, Resource type Table, table hr.salaries, Permission table.read. The result is Denied, naming the deny on the grant.

To keep every service account out instead, create a forbid policy: Permissions table.read, Applies to principals Service account, Scope Table, Condition resource.Name.startsWith("hr.").

Tables restricted with the older per-user schema permissions show under Legacy restrictions on the table's access panel and the user's page, where they can be edited or removed (legacy table restrictions). Such a restriction narrows every grant its user holds in the account, deployment-wide grants such as Administrator included. It names one user; it cannot be placed on a group.