jessebehrens / SnowflakeMiscellaneous

Small code snippets for customers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SnowflakeMiscellaneous

This repository is to provide small code snippets for customers to demonstrate specific Snowflake features.

  • RowAccessPolicies.sql - This code is designed to create sample roles, data, and tables for common demonstration purposes. Row base access policies are applied to these common datasets to demonstrate how specific roles can only see certain rows within the same table.
    1. Lines 1 through 62 are just setting up my environment. I wanted us to have common roles, data, and environments. The first 62 lines are just setting this up so we have a common ground to work through. They are not needed for production environments
    2. Lines 63 through 84 are actually creating the row base access policies
    3. Lines 63 through 73 create a mapping table that maps what roles can access what rows
    4. Lines 76 through 81 create the actual policy object
    5. Line 84 applies the policy to our table. This is a reusable object and can be used on multiple objects if we choose
    6. Lines 86 through 99 just simulate the different roles and show how the results differ based on the roles a user has

About

Small code snippets for customers