Apply row access policy to current tables and future created tables and views

Viewed 34

We are planning on using row access policy in snowflake. I can apply the policy to individual tables and view.

Question:
Is there a way to apply to all tables and views in the database ?
Is there a way to apply to future tables as well as and when they are created?

1 Answers

There isn't an official feature to apply a row access policy to multiple tables in a single command.

Row access policies need to specify columns/values to be passed into the policy for each table. Any way to apply a row access policy to multiple tables (including future tables) would require you to identify which columns/values to pass in for all those tables.

In theory, you could write a script that scans the tables, deduces which column values to pass as arguments to your row access policy, and constructs a command to apply the policy to each table.

But there's no way to constrain the creation of new tables to ensure they will always have columns with specific names or characteristics. So if you're allowing new tables to be created, then there's a possibility that a table will be created that cannot have a given row access policy applied to it. Therefore, it wouldn't be sensible to have a command that causes a row access policy to get applied automatically to future tables.

Related