Home » Bigquery » Tutorials » Create row access policy

BigQuery Create row access policy

Row-level security lets you filter data and enables access to specific rows in a table, based on qualifying user conditions.. It provides fine-grained access control to a subset of data in a BigQuery table, by means of row-level access policies

Create row access policy example

\n    CREATE OR REPLACE ROW ACCESS POLICY My_apac_filter\n    ON project.dataset.My_table\n    GRANT TO ("user:xyz@example.com")\n    FILTER USING (region = "apac");\n
\n\n

Creating a row access policy with multiple grantees

\n
\n    CREATE ROW ACCESS POLICY My_us_filter\n    ON project.dataset.My_table\n    GRANT TO ("user:john@example.com", "group:sales-us@example.com", "group:sales-managers@example.com")\n    FILTER USING (region = "us");\n
\n\n\n

Creating a row access policy to a group

\n
\n    CREATE OR REPLACE ROW ACCESS POLICY My_apac_filter\n    ON project.dataset.My_table\n    GRANT TO ("group:sales-apac@example.com")\n    FILTER USING (region = "apac");\n
\n\n

Creating a row access policy with allAuthenticatedUsers as the grantees

\n
\n    CREATE ROW ACCESS POLICY My_us_filter\n    ON project.dataset.My_table\n    GRANT TO ("allAuthenticatedUsers")\n    FILTER USING (region = "us");\n

Syntax reference

  {CREATE ROW ACCESS POLICY | CREATE ROW ACCESS POLICY IF NOT EXISTS |\n  CREATE OR REPLACE ROW ACCESS POLICY}\n  row_access_policy_name ON table_name\n  [GRANT TO (grantee_list)]\n  FILTER USING (filter_expression);