Column Access Policy
Use the CREATE ACCESS POLICY statement to create a column access policy for a specific column in a table. Creating an access policy depends on the expressions specified when creating the policy, and also on the following:
Example
Suppose you want to prevent users from viewing a specific column in a table. This example shows how to create an access policy that masks column A in Table1.
Run the following SQL command:
=> SELECT * FROM Table1;
Table1 appears as follows:
A | B --+---------- 1 | one 2 | two 3 | three 4 | four
Create the following column access policy:
=> CREATE ACCESS POLICY on Table1 FOR column A NULL::int enable;
Re-run the SQL command:
=> SELECT * FROM Table1;
The following is returned:
A | B --+---------- | one | two | three | four
Note that no values appear in column A because the access policy prevents the return of this data (NULL::int
).