Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find tables using row access policies in Snowflake

I have created few tables in a schema and a row access policy with "create or replace row access policy <policy_name>.." command. Then I have added the row access policy to the tables with "alter table <table_name> add row access policy <policy_name>..."

It is working as expected. My question is, In future, If I want to get a list of tables in a schema that are having the row access policy, How can I get that?

"show tables .. " command doesn't show that table has a row access policy.

like image 416
jsrathnayake Avatar asked Oct 26 '25 04:10

jsrathnayake


1 Answers

I just had the same issue and I think I figured it out.

Check out the docs here - https://docs.snowflake.com/en/sql-reference/functions/policy_references.html.

You can search for row access policies based on the policy name or the object name that you want to check.

In your example, let's say your table is called my_db.my_schema.my_table. To view row access policies on the table, just run:

use database my_db;
use schema information_schema;
select *
  from table(information_schema.policy_references(ref_entity_name => 'my_db.my_schema.my_table', ref_entity_domain => 'table'));

like image 180
Jeremy Holtzman Avatar answered Oct 28 '25 02:10

Jeremy Holtzman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!