<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Access policies</title>
    <link>/en/admin/db-users-and-privileges/access-policies/</link>
    <description>Recent content in Access policies on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/admin/db-users-and-privileges/access-policies/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Admin: Creating column access policies</title>
      <link>/en/admin/db-users-and-privileges/access-policies/creating-column-access-policies/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/db-users-and-privileges/access-policies/creating-column-access-policies/</guid>
      <description>
        
        
        &lt;p&gt;&lt;span class=&#34;sql&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-access-policy/#&#34;&gt;CREATE ACCESS POLICY&lt;/a&gt;&lt;/span&gt; can create access policies on individual table columns, one policy per column. Each column access policy lets you specify, for different users and roles, various levels of access to the data of that column. The column access expression can also specify how to render column data for users and roles.&lt;/p&gt;
&lt;p&gt;The following example creates an access policy on the &lt;code&gt;customer_address&lt;/code&gt; column in the &lt;code&gt;client_dimension&lt;/code&gt; table. This access policy gives non-superusers with the &lt;code&gt;administrator&lt;/code&gt; role full access to all data in that column, but masks customer address data from all other users:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE ACCESS POLICY ON public.customer_dimension FOR COLUMN customer_address
-&amp;gt; CASE
-&amp;gt; WHEN ENABLED_ROLE(&amp;#39;administrator&amp;#39;) THEN customer_address
-&amp;gt; ELSE &amp;#39;**************&amp;#39;
-&amp;gt; END ENABLE;
CREATE ACCESS POLICY
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

Database user roles are compatible with LDAP users. You do not need separate LDAP roles to use column access policies with LDAP users.

&lt;/div&gt;
&lt;p&gt;The database uses this policy to determine the access it gives to users MaxineT and MikeL, who are assigned &lt;code&gt;employee&lt;/code&gt; and &lt;code&gt;administrator&lt;/code&gt; roles, respectively. When these users query the &lt;code&gt;customer_dimension&lt;/code&gt; table, the database applies the column access policy expression as follows:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; \c - MaxineT;
You are now connected as user &amp;#34;MaxineT&amp;#34;.
=&amp;gt; SET ROLE employee;
SET
=&amp;gt; SELECT customer_type, customer_name, customer_gender, customer_address, customer_city FROM customer_dimension;
 customer_type |      customer_name      | customer_gender | customer_address |  customer_city
---------------+-------------------------+-----------------+------------------+------------------
 Individual    | Craig S. Robinson       | Male            | **************   | Fayetteville
 Individual    | Mark M. Kramer          | Male            | **************   | Joliet
 Individual    | Barbara S. Farmer       | Female          | **************   | Alexandria
 Individual    | Julie S. McNulty        | Female          | **************   | Grand Prairie
 ...

=&amp;gt; \c - MikeL
You are now connected as user &amp;#34;MikeL&amp;#34;.
=&amp;gt; SET ROLE administrator;
SET
=&amp;gt; SELECT customer_type, customer_name, customer_gender, customer_address, customer_city FROM customer_dimension;
 customer_type |      customer_name      | customer_gender | customer_address |  customer_city
---------------+-------------------------+-----------------+------------------+------------------
 Individual    | Craig S. Robinson       | Male            | 138 Alden Ave    | Fayetteville
 Individual    | Mark M. Kramer          | Male            | 311 Green St     | Joliet
 Individual    | Barbara S. Farmer       | Female          | 256 Cherry St    | Alexandria
 Individual    | Julie S. McNulty        | Female          | 459 Essex St     | Grand Prairie
 ...
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&gt;
&lt;p&gt;The following limitations apply to access policies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A column can have only one access policy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Column access policies cannot be set on columns of complex types other than native arrays.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Column access policies cannot be set for materialized columns on flex tables. While it is possible to set an access policy for the &lt;code&gt;__raw__&lt;/code&gt; column, doing so restricts access to the whole table.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Row access policies are invalid on temporary tables and tables with aggregate projections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Access policy expressions cannot contain:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Subqueries&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Aggregate functions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Analytic functions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;User-defined transform functions (UDTF)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the query optimizer cannot replace a deterministic expression that involves only constants with their computed values, it blocks all DML operations such as &lt;span class=&#34;sql&#34;&gt;INSERT&lt;/span&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;


      </description>
    </item>
    
    <item>
      <title>Admin: Creating row access policies</title>
      <link>/en/admin/db-users-and-privileges/access-policies/creating-row-access-policies/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/db-users-and-privileges/access-policies/creating-row-access-policies/</guid>
      <description>
        
        
        &lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-access-policy/#&#34;&gt;CREATE ACCESS POLICY&lt;/a&gt; can create a single row access policy for a given table. This policy lets you specify for different users and roles various levels of access to table row data. When a user launches a query, the database evaluates the access policy&#39;s WHERE expression against all table rows. The query returns with only those rows where the expression evaluates to true for the current user or role.&lt;/p&gt;
&lt;p&gt;For example, you might want to specify different levels of access to table &lt;code&gt;store.store_store_sales&lt;/code&gt; for four roles:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;employee&lt;/code&gt;: Users with this role should only access sales records that identify them as the employee, in column &lt;code&gt;employee_key&lt;/code&gt;. The following query shows how many sales records (in &lt;code&gt;store.store_sales_fact&lt;/code&gt;) are associated with each user (in &lt;code&gt;public.emp_dimension&lt;/code&gt;):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT COUNT(sf.employee_key) AS &amp;#39;Total Sales&amp;#39;, sf.employee_key, ed.user_name FROM store.store_sales_fact sf
     JOIN emp_dimension ed ON sf.employee_key=ed.employee_key
     WHERE ed.job_title=&amp;#39;Sales Associate&amp;#39; GROUP BY sf.employee_key, ed.user_name ORDER BY sf.employee_key

 Total Sales | employee_key |  user_name
-------------+--------------+-------------
         533 |          111 | LucasLC
         442 |          124 | JohnSN
         487 |          127 | SamNS
         477 |          132 | MeghanMD
         545 |          140 | HaroldON
         ...
         563 |         1991 | MidoriMG
         367 |         1993 | ThomZM
(318 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;regional_manager&lt;/code&gt;: Users with this role (&lt;code&gt;public.emp_dimension&lt;/code&gt;) should only access sales records for the sales region that they manage (&lt;code&gt;store.store_dimension&lt;/code&gt;):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT distinct sd.store_region, ed.user_name, ed.employee_key, ed.job_title FROM store.store_dimension sd
     JOIN emp_dimension ed ON sd.store_region=ed.employee_region WHERE ed.job_title = &amp;#39;Regional Manager&amp;#39;;
 store_region | user_name | employee_key |    job_title
--------------+-----------+--------------+------------------
 West         | JamesGD   |         1070 | Regional Manager
 South        | SharonDM  |         1710 | Regional Manager
 East         | BenOV     |          593 | Regional Manager
 MidWest      | LilyCP    |          611 | Regional Manager
 NorthWest    | CarlaTG   |         1058 | Regional Manager
 SouthWest    | MarcusNK  |          150 | Regional Manager
(6 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;dbadmin&lt;/code&gt; and &lt;code&gt;administrator&lt;/code&gt;: Users with these roles have unlimited access to all table data.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Given these users and the data associated with them, you can create a row access policy on &lt;code&gt;store.store_store_sales&lt;/code&gt; that looks like this:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE ACCESS POLICY ON store.store_sales_fact FOR ROWS WHERE
   (ENABLED_ROLE(&amp;#39;employee&amp;#39;)) AND (store.store_sales_fact.employee_key IN
     (SELECT employee_key FROM public.emp_dimension WHERE user_name=CURRENT_USER()))
   OR
   (ENABLED_ROLE(&amp;#39;regional_manager&amp;#39;)) AND (store.store_sales_fact.store_key IN
     (SELECT sd.store_key FROM store.store_dimension sd
      JOIN emp_dimension ed ON sd.store_region=ed.employee_region WHERE ed.user_name = CURRENT_USER()))
   OR ENABLED_ROLE(&amp;#39;dbadmin&amp;#39;)
   OR ENABLED_ROLE (&amp;#39;administrator&amp;#39;)
ENABLE;
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;admonition important&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Important&lt;/h4&gt;
In this example, the row policy limits access to a set of roles that are explicitly included in policy&#39;s WHERE expression. All other roles and users are implicitly denied access to the table data.
&lt;/div&gt;
&lt;p&gt;The following examples indicate the different levels of access that are available to users with the specified roles:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;dbadmin&lt;/code&gt; has access to all rows in &lt;code&gt;store.store_sales_fact&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; \c
You are now connected as user &amp;#34;dbadmin&amp;#34;.
=&amp;gt; SELECT count(*) FROM store.store_sales_fact;
  count
---------
 5000000
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;User &lt;code&gt;LilyCP&lt;/code&gt; has the role of &lt;code&gt;regional_manager&lt;/code&gt;, so she can access all sales data of the Midwest region that she manages:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; \c - LilyCP;
You are now connected as user &amp;#34;LilyCP&amp;#34;.
=&amp;gt; SET ROLE regional_manager;
SET
=&amp;gt; SELECT count(*) FROM store.store_sales_fact;
 count
--------
 782272
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;User &lt;code&gt;SamRJ&lt;/code&gt; has the role of &lt;code&gt;employee&lt;/code&gt;, so he can access only the sales data that he is associated with:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; \c - SamRJ;
You are now connected as user &amp;#34;SamRJ&amp;#34;.
=&amp;gt; SET ROLE employee;
SET
=&amp;gt; SELECT count(*) FROM store.store_sales_fact;
 count
-------
   417
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&gt;
&lt;p&gt;The following limitations apply to row access policies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A table can have only one row access policy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Row access policies are invalid on the following tables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Tables with aggregate projections&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Temporary tables&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;System tables&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Views&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You cannot create &lt;a href=&#34;../../../../en/admin/managing-queries/directed-queries/&#34;&gt;directed queries&lt;/a&gt; on a table with a row access policy.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Access policies and DML operations</title>
      <link>/en/admin/db-users-and-privileges/access-policies/access-policies-and-dml-operations/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/db-users-and-privileges/access-policies/access-policies-and-dml-operations/</guid>
      <description>
        
        
        &lt;p&gt;By default, the database abides by a rule that a user can only edit what they can see. That is, you must be able to view all rows and columns in the table in their original values (as stored in the table) and in their originally defined data types to perform actions that modify data on a table. For example, if a column is defined as VARCHAR(9) and an access policy on that column specifies the same column as VARCHAR(10), users using the access policy will be unable to perform the following operations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;INSERT&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;UPDATE&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;DELETE&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;MERGE&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;COPY&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can override this behavior by specifying GRANT TRUSTED in a &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-access-policy/&#34;&gt;new&lt;/a&gt; or &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-access-policy/&#34;&gt;existing&lt;/a&gt; access policy. This option forces the access policy to defer entirely to explicit GRANT statements when assessing whether a user can perform the above operations.&lt;/p&gt;
&lt;p&gt;You can view existing access policies with the &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/access-policy/#&#34;&gt;ACCESS_POLICY&lt;/a&gt; system table.&lt;/p&gt;
&lt;h2 id=&#34;row-access&#34;&gt;Row access&lt;/h2&gt;
&lt;p&gt;On tables where a row access policy is enabled, you can only perform DML operations when the condition in the row access policy evaluates to TRUE. For example:&lt;/p&gt;
&lt;p&gt;t1 appears as follows:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt; A | B
---+---
 1 | 1
 2 | 2
 3 | 3
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Create the following row access policy on t1:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE ACCESS POLICY ON t1 for ROWS
WHERE enabled_role(&amp;#39;manager&amp;#39;)
OR
A&amp;lt;2
ENABLE;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;With this policy enabled, the following behavior exists for users who want to perform DML operations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A user with the manager role can perform DML on all rows in the table, because the WHERE clause in the policy evaluates to TRUE.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Users with non-manager roles can only perform a SELECT to return data in column A that has a value of less than two. If the access policy has to read the data in the table to confirm a condition, it does not allow DML operations.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;column-access&#34;&gt;Column access&lt;/h2&gt;
&lt;p&gt;On tables where a column access policy is enabled, you can perform DML operations if you can view the entire column in its originally defined type.&lt;/p&gt;
&lt;p&gt;Suppose table t1 is created with the following data types and values:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE t1 (A int, B int);
=&amp;gt; INSERT INTO t1 VALUES (1,2);
=&amp;gt; SELECT * FROM t1;
 A | B
---+---
 1 | 2
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Suppose the following access policy is created, which coerces the data type of column A from INT to VARCHAR(20) at execution time.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE ACCESS POLICY on t1 FOR column A A::VARCHAR(20) ENABLE;
Column &amp;#34;A&amp;#34; is of type int but expression in Access Policy is of type varchar(20). It will be coerced at execution time
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this case, u1 can view column A in its entirety, but because the active access policy doesn&#39;t specify column A&#39;s original data type, u1 cannot perform DML operations on column A.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; \c - u1
You are now connected as user &amp;#34;u1&amp;#34;.
=&amp;gt; SELECT A FROM t1;
 A
---
 1
(1 row)

=&amp;gt; INSERT INTO t1 VALUES (3);
ERROR 6538:  Unable to INSERT: &amp;#34;Access denied due to active access policy on table &amp;#34;t1&amp;#34; for column &amp;#34;A&amp;#34;&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a name=&#34;Overridi&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;overriding-default-behavior-with-grant-trusted&#34;&gt;Overriding default behavior with GRANT TRUSTED&lt;/h2&gt;
&lt;p&gt;Specifying GRANT TRUSTED in an access policy overrides the default behavior (&amp;quot;users can only edit what they can see&amp;quot;) and instructs the access policy to defer entirely to explicit GRANT statements when assessing whether a user can perform a DML operation.

&lt;div class=&#34;admonition important&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Important&lt;/h4&gt;
GRANT TRUSTED can allow users to make changes to tables even if the data is obscured by the access policy. In these cases, certain users who are constrained by the access policy but also have GRANTs on the table can make changes to the data that they cannot view or verify.
&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;GRANT TRUSTED is useful in cases where the form the data is stored in doesn&#39;t match its semantically &amp;quot;true&amp;quot; form.&lt;/p&gt;
&lt;p&gt;For example, when integrating with &lt;a href=&#34;../../../../en/voltage-securedata-integration/automating-encryption-and-decryption-with-access-policies/&#34;&gt;Voltage SecureData&lt;/a&gt;, a common use case is storing encrypted data with &lt;a href=&#34;../../../../en/voltage-securedata-integration/voltage-securedata-integration-function-reference/voltagesecureprotect/#&#34;&gt;VoltageSecureProtect&lt;/a&gt;, where decryption is left to a case expression in an access policy that calls &lt;a href=&#34;../../../../en/voltage-securedata-integration/voltage-securedata-integration-function-reference/voltagesecureaccess/#&#34;&gt;VoltageSecureAccess&lt;/a&gt;. In this case, while the decrypted form is intuitively understood to be the data&#39;s &amp;quot;true&amp;quot; form, it&#39;s still stored in the table in its encrypted form; users who can view the decrypted data wouldn&#39;t see the data as it was stored and therefore wouldn&#39;t be able to perform DML operations. You can use GRANT TRUSTED to override this behavior and allow users to perform these operations if they have the grants.&lt;/p&gt;
&lt;p&gt;In this example, the customer_info table contains columns for the customer first and last name and SSN. SSNs are sensitive and access to it should be controlled, so it is encrypted with &lt;a href=&#34;../../../../en/voltage-securedata-integration/voltage-securedata-integration-function-reference/voltagesecureprotect/#&#34;&gt;VoltageSecureProtect&lt;/a&gt; as it is inserted into the table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; CREATE TABLE customer_info(first_name VARCHAR, last_name VARCHAR, ssn VARCHAR);
=&amp;gt; INSERT INTO customer_info SELECT &amp;#39;Alice&amp;#39;, &amp;#39;Smith&amp;#39;, VoltageSecureProtect(&amp;#39;998-42-4910&amp;#39; USING PARAMETERS format=&amp;#39;ssn&amp;#39;);
=&amp;gt; INSERT INTO customer_info SELECT &amp;#39;Robert&amp;#39;, &amp;#39;Eve&amp;#39;, VoltageSecureProtect(&amp;#39;899-28-1303&amp;#39; USING PARAMETERS format=&amp;#39;ssn&amp;#39;);
=&amp;gt; SELECT * FROM customer_info;
 first_name | last_name |     ssn
------------+-----------+-------------
 Alice      | Smith     | 967-63-8030
 Robert     | Eve       | 486-41-3371
(2 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this system, the role &amp;quot;trusted_ssn&amp;quot; identifies privileged users for which the database will decrypt the values of the &amp;quot;ssn&amp;quot; column with &lt;a href=&#34;../../../../en/voltage-securedata-integration/voltage-securedata-integration-function-reference/voltagesecureaccess/#&#34;&gt;VoltageSecureAccess&lt;/a&gt;. To allow these privileged users to perform DML operations for which they have grants, you might use the following access policy:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE ACCESS POLICY ON customer_info FOR COLUMN ssn
  CASE WHEN enabled_role(&amp;#39;trusted_ssn&amp;#39;) THEN VoltageSecureAccess(ssn USING PARAMETERS format=&amp;#39;ssn&amp;#39;)
  ELSE ssn END
  GRANT TRUSTED
  ENABLE;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Again, note that GRANT TRUSTED allows &lt;em&gt;all&lt;/em&gt; users with GRANTs on the table to perform the specified operations, including users without the &amp;quot;trusted_ssn&amp;quot; role.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Access policies and query optimization</title>
      <link>/en/admin/db-users-and-privileges/access-policies/access-policies-and-query-optimization/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/db-users-and-privileges/access-policies/access-policies-and-query-optimization/</guid>
      <description>
        
        
        &lt;p&gt;Access policies affect the projection designs that the Database Designer produces, and the plans that the optimizer creates for query execution.&lt;/p&gt;
&lt;h2 id=&#34;projection-designs&#34;&gt;Projection designs&lt;/h2&gt;
&lt;p&gt;When Database Designer creates projections for a given table, it takes into account access policies that apply to the current user. The set of projections that Database Designer produces for the table are optimized for that user&#39;s access privileges, and other users with similar access privileges. However, these projections might be less than optimal for users with different access privileges. These differences might have some effect on how efficiently the database processes queries for the second group of users. When you evaluate projection designs for a table, choose a design that optimizes access for all authorized users.&lt;/p&gt;
&lt;h2 id=&#34;query-rewrite&#34;&gt;Query rewrite&lt;/h2&gt;
&lt;p&gt;The optimizer enforces access policies by rewriting user queries in its query plan, which can affect query performance. For example, the clients table has row and column access policies, both enabled. When a user queries this table, the query optimizer produces a plan that rewrites the query so it includes both policies:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM clients;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The query optimizer produces a query plan that rewrites the query as follows:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT * FROM (
SELECT custID, password, CASE WHEN enabled_role(&amp;#39;manager&amp;#39;) THEN SSN ELSE substr(SSN, 8, 4) END AS SSN FROM clients
WHERE enabled_role(&amp;#39;broker&amp;#39;) AND
  clients.clientID IN (SELECT brokers.clientID FROM brokers WHERE broker_name = CURRENT_USER())
) clients;
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Admin: Managing access policies</title>
      <link>/en/admin/db-users-and-privileges/access-policies/managing-access-policies/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/db-users-and-privileges/access-policies/managing-access-policies/</guid>
      <description>
        
        
        &lt;p&gt;By default, you can only manage access policies on tables that you own. You can optionally restrict access policy management to superusers with the AccessPolicyManagementSuperuserOnly parameter (false by default):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER DATABASE DEFAULT SET PARAMETER AccessPolicyManagementSuperuserOnly = 1;
ALTER DATABASE
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can view and manage access policies for tables in several ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Viewing&#34;&gt;View access policies&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Modifyin&#34;&gt;Modify the expression of an access policy&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Enabling&#34;&gt;Enable or disable access policies&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Copying&#34;&gt;Copy access policies to another table&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name=&#34;Viewing&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;viewing-access-policies&#34;&gt;Viewing access policies&lt;/h2&gt;
&lt;p&gt;You can view access policies in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Query system table &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/access-policy/#&#34;&gt;ACCESS_POLICY&lt;/a&gt;. For example, the following query returns all access policies on table &lt;code&gt;public.customer_dimension&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; \x
=&amp;gt; SELECT policy_type, is_policy_enabled, table_name, column_name, expression FROM access_policy WHERE table_name = &amp;#39;public.customer_dimension&amp;#39;;
-[ RECORD 1 ]-----+----------------------------------------------------------------------------------------
policy_type       | Column Policy
is_policy_enabled | Enabled
table_name        | public.customer_dimension
column_name       | customer_address
expression        | CASE WHEN enabled_role(&amp;#39;administrator&amp;#39;) THEN customer_address ELSE &amp;#39;**************&amp;#39; END
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Export table DDL from the database catalog with &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/catalog-functions/export-tables/#&#34;&gt;EXPORT_TABLES&lt;/a&gt;, &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/catalog-functions/export-objects/#&#34;&gt;EXPORT_OBJECTS&lt;/a&gt;, or &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/catalog-functions/export-catalog/#&#34;&gt;EXPORT_CATALOG&lt;/a&gt;. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT export_tables(&amp;#39;&amp;#39;,&amp;#39;customer_dimension&amp;#39;);
                                export_tables
-----------------------------------------------------------------------------
CREATE TABLE public.customer_dimension
(
    customer_key int NOT NULL,
    customer_type varchar(16),
    customer_name varchar(256),
    customer_gender varchar(8),
    ...
    CONSTRAINT C_PRIMARY PRIMARY KEY (customer_key) DISABLED
);

CREATE ACCESS POLICY ON public.customer_dimension FOR COLUMN customer_address CASE WHEN enabled_role(&amp;#39;administrator&amp;#39;) THEN customer_address ELSE &amp;#39;**************&amp;#39; END ENABLE;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name=&#34;Modifyin&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;modifying-access-policy-expression&#34;&gt;Modifying access policy expression&lt;/h2&gt;
&lt;p&gt;ALTER ACCESS POLICY can modify the expression of an existing access policy. For example, you can modify the access policy in the earlier example by extending access to the dbadmin role:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER ACCESS POLICY ON public.customer_dimension FOR COLUMN customer_address
    CASE WHEN enabled_role(&amp;#39;dbadmin&amp;#39;) THEN customer_address
         WHEN enabled_role(&amp;#39;administrator&amp;#39;) THEN customer_address
         ELSE &amp;#39;**************&amp;#39; END ENABLE;
ALTER ACCESS POLICY
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Querying system table ACCESS_POLICY confirms this change:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT policy_type, is_policy_enabled, table_name, column_name, expression FROM access_policy
  WHERE table_name = &amp;#39;public.customer_dimension&amp;#39; AND column_name=&amp;#39;customer_address&amp;#39;;
-[ RECORD 1 ]-----+-------------------------------------------------------------------------------------------------------------------------------------------
policy_type       | Column Policy
is_policy_enabled | Enabled
table_name        | public.customer_dimension
column_name       | customer_address
expression        | CASE WHEN enabled_role(&amp;#39;dbadmin&amp;#39;) THEN customer_address WHEN enabled_role(&amp;#39;administrator&amp;#39;) THEN customer_address ELSE &amp;#39;**************&amp;#39; END
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a name=&#34;Enabling&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;enabling-and-disabling-access-policies&#34;&gt;Enabling and disabling access policies&lt;/h2&gt;
&lt;p&gt;Owners of a table can enable and disable its row and column access policies.&lt;/p&gt;
&lt;h3 id=&#34;row-access-policies&#34;&gt;Row access policies&lt;/h3&gt;
&lt;p&gt;You enable and disable row access policies on a table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ALTER ACCESS POLICY ON [&lt;span class=&#34;code-variable&#34;&gt;schema&lt;/span&gt;.]&lt;span class=&#34;code-variable&#34;&gt;table&lt;/span&gt; FOR ROWS { ENABLE | DISABLE }
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following examples disable and then re-enable the row access policy on table &lt;code&gt;customer_dimension&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER ACCESS POLICY ON customer_dimension FOR ROWS DISABLE;
ALTER ACCESS POLICY
=&amp;gt; ALTER ACCESS POLICY ON customer_dimension FOR ROWS ENABLE;
ALTER ACCESS POLICY
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;column-access-policies&#34;&gt;Column access policies&lt;/h3&gt;
&lt;p&gt;You enable and disable access policies on a table column as follows:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ALTER ACCESS POLICY ON [&lt;span class=&#34;code-variable&#34;&gt;schema&lt;/span&gt;.]&lt;span class=&#34;code-variable&#34;&gt;table&lt;/span&gt; FOR COLUMN &lt;span class=&#34;code-variable&#34;&gt;column&lt;/span&gt; { ENABLE | DISABLE }
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following examples disable and then re-enable the same column access policy on &lt;code&gt;customer_dimension.customer_address&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER ACCESS POLICY ON public.customer_dimension FOR COLUMN customer_address DISABLE;
ALTER ACCESS POLICY
=&amp;gt; ALTER ACCESS POLICY ON public.customer_dimension FOR COLUMN customer_address ENABLE;
ALTER ACCESS POLICY
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a name=&#34;Copying&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;copying-access-polices&#34;&gt;Copying access polices&lt;/h2&gt;
&lt;p&gt;You copy access policies from one table to another as follows. Non-superusers must have ownership of both the source and destination tables:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ALTER ACCESS POLICY ON [schema.]&lt;span class=&#34;code-variable&#34;&gt;table&lt;/span&gt; { FOR COLUMN &lt;span class=&#34;code-variable&#34;&gt;column&lt;/span&gt; | FOR ROWS } COPY TO TABLE &lt;span class=&#34;code-variable&#34;&gt;table&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When you create a copy of a table or move its contents with the following functions (but not &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-table/&#34;&gt;CREATE TABLE AS SELECT or CREATE TABLE LIKE&lt;/a&gt;), the access policies of the original table are copied to the new/destination table:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/table-functions/copy-table/#&#34;&gt;COPY_TABLE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/copy-partitions-to-table/#&#34;&gt;COPY_PARTITIONS_TO_TABLE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/move-partitions-to-table/#&#34;&gt;MOVE_PARTITIONS_TO_TABLE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/swap-partitions-between-tables/#&#34;&gt;SWAP_PARTITIONS_BETWEEN_TABLES&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To copy access policies to another table, use &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-access-policy/#&#34;&gt;ALTER ACCESS POLICY&lt;/a&gt;.

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

If you rename a table with &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/&#34;&gt;ALTER TABLE...RENAME TO&lt;/a&gt;, the access policies that were stored under the previous name are stored under the table&#39;s new name.

&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;For example, you can copy a row access policy as follows:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER ACCESS POLICY ON public.emp_dimension FOR ROWS COPY TO TABLE public.regional_managers_dimension;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following statement copies the access policy on column &lt;code&gt;employee_key&lt;/code&gt; from table &lt;code&gt;public.emp_dimension&lt;/code&gt; to &lt;code&gt;store.store_sales_fact&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER ACCESS POLICY ON public.emp_dimension FOR COLUMN employee_key COPY TO TABLE store.store_sales_fact;
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

The copied policy retains the source policy&#39;s enabled/disabled settings.

&lt;/div&gt;

      </description>
    </item>
    
  </channel>
</rss>
