{"id":611,"date":"2025-02-01T06:10:24","date_gmt":"2025-02-01T06:10:24","guid":{"rendered":"https:\/\/datadandies.nl\/?p=611"},"modified":"2025-02-01T06:11:56","modified_gmt":"2025-02-01T06:11:56","slug":"611","status":"publish","type":"post","link":"https:\/\/datadandies.nl\/index.php\/2025\/02\/01\/611\/","title":{"rendered":"Reduce administrative overhead in Snowflake with Privilege Inheritance in Role Hierarchies"},"content":{"rendered":"\n<p>Privilege inheritance in Snowflake&#8217;s role hierarchy is a powerful feature that simplifies access management and reduces administrative overhead.<\/p>\n\n\n\n<p>In Snowflake, roles can be granted to other roles, creating a hierarchical structure. Privileges associated with a role are inherited by any roles above it in the hierarchy. This means that when you grant a privilege to a lower-level role, all roles above it in the hierarchy automatically receive that privilege as well.<\/p>\n\n\n\n<p>Let me illustrate this with an example:<\/p>\n\n\n\n<p>Let&#8217;s consider a simple role hierarchy:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\" start=\"1\">\n<li>ANALYST_ROLE (lowest level)<\/li>\n\n\n\n<li>DATA_ENGINEER_ROLE (middle level)<\/li>\n\n\n\n<li>SYSADMIN (highest level)<\/li>\n<\/ol>\n\n\n\n<p>We can set up this hierarchy using the following commands:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1.3rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * 1.3rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">SQL<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"USE ROLE SECURITYADMIN;\n\nGRANT ROLE ANALYST_ROLE TO ROLE DATA_ENGINEER_ROLE;\n\nGRANT ROLE DATA_ENGINEER_ROLE TO ROLE SYSADMIN;\" style=\"color:#D4D4D4;display:none\" aria-label=\"Kopieer\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">USE<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ROLE<\/span><span style=\"color: #D4D4D4\"> SECURITYADMIN;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">GRANT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ROLE<\/span><span style=\"color: #D4D4D4\"> ANALYST_ROLE <\/span><span style=\"color: #569CD6\">TO<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ROLE<\/span><span style=\"color: #D4D4D4\"> DATA_ENGINEER_ROLE;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">GRANT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ROLE<\/span><span style=\"color: #D4D4D4\"> DATA_ENGINEER_ROLE <\/span><span style=\"color: #569CD6\">TO<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ROLE<\/span><span style=\"color: #D4D4D4\"> SYSADMIN;<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#1E1E1E;color:#c7c7c7;font-size:12px;line-height:1;position:relative\">SQL<\/span><\/div>\n\n\n\n<p>Now, let&#8217;s grant some privileges:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1.3rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * 1.3rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">SQL<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"GRANT USAGE ON DATABASE SOURCE_DB TO ROLE ANALYST_ROLE;\n\nGRANT SELECT ON ALL TABLES IN SCHEMA SOURCE_DB.PUBLIC TO ROLE ANALYST_ROLE;\n\nGRANT SELECT ON FUTURE TABLES IN SCHEMA SOURCE_DB.PUBLIC TO ROLE ANALYST_ROLE;\" style=\"color:#D4D4D4;display:none\" aria-label=\"Kopieer\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">GRANT<\/span><span style=\"color: #D4D4D4\"> USAGE <\/span><span style=\"color: #569CD6\">ON<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">DATABASE<\/span><span style=\"color: #D4D4D4\"> SOURCE_DB <\/span><span style=\"color: #569CD6\">TO<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ROLE<\/span><span style=\"color: #D4D4D4\"> ANALYST_ROLE;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">GRANT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ON<\/span><span style=\"color: #D4D4D4\"> ALL TABLES <\/span><span style=\"color: #569CD6\">IN<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">SCHEMA<\/span><span style=\"color: #D4D4D4\"> SOURCE_DB.PUBLIC <\/span><span style=\"color: #569CD6\">TO<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ROLE<\/span><span style=\"color: #D4D4D4\"> ANALYST_ROLE;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">GRANT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ON<\/span><span style=\"color: #D4D4D4\"> FUTURE TABLES <\/span><span style=\"color: #569CD6\">IN<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">SCHEMA<\/span><span style=\"color: #D4D4D4\"> SOURCE_DB.PUBLIC <\/span><span style=\"color: #569CD6\">TO<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">ROLE<\/span><span style=\"color: #D4D4D4\"> ANALYST_ROLE;<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#1E1E1E;color:#c7c7c7;font-size:12px;line-height:1;position:relative\">SQL<\/span><\/div>\n\n\n\n<p>With this setup:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\" start=\"1\">\n<li>ANALYST_ROLE has USAGE privilege on SOURCE_DB and SELECT privilege on all tables in SOURCE_DB.PUBLIC schema.<\/li>\n\n\n\n<li>DATA_ENGINEER_ROLE automatically inherits these privileges from ANALYST_ROLE.<\/li>\n\n\n\n<li>SYSADMIN also inherits these privileges through DATA_ENGINEER_ROLE.<\/li>\n<\/ol>\n\n\n\n<p>This inheritance simplifies management because:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\" start=\"1\">\n<li>You only need to grant privileges once at the lowest appropriate level.<\/li>\n\n\n\n<li>When you add new objects (e.g. tables) to SOURCE_DB.PUBLIC, all roles in the hierarchy automatically get access without additional grants.<\/li>\n\n\n\n<li>If you need to modify access, you can do it at one level, and the changes propagate up the hierarchy.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Privilege inheritance in Snowflake&#8217;s role hierarchy is a powerful feature that simplifies access management and reduces administrative overhead. In Snowflake, roles can be granted to other roles, creating a hierarchical structure. Privileges associated with a role are inherited by any roles above it in the hierarchy. This means that when you grant a privilege to&hellip;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/datadandies.nl\/index.php\/2025\/02\/01\/611\/\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[15,40,4],"class_list":["post-611","post","type-post","status-publish","format-standard","hentry","category-blog","tag-cybersecurity","tag-snowflake","tag-sql"],"_links":{"self":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/comments?post=611"}],"version-history":[{"count":3,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/611\/revisions"}],"predecessor-version":[{"id":614,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/611\/revisions\/614"}],"wp:attachment":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/media?parent=611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/categories?post=611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/tags?post=611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}