CREATE POLICY
create_policy
name
is the name of the new policy. This must be distinct from any other policy name for thattable.table_name
is the name of the table that the policy applies to.PERMISSIVE
/RESTRICTIVE
specifies that the policy is permissive or restrictive.While applying policies to a table, permissive policies are combined together using a logical OR operator,while restrictive policies are combined using logical AND operator. Restrictive policies are used toreduce the number of records that can be accessed. Default is permissive.role_name
is the role(s) to which the policy is applied. Default isPUBLIC
which applies thepolicy to all roles.check_expression
is a SQL conditional expression that is used only forINSERT
andUPDATE
queries. Only rows for which the expression evaluates to true will be allowed in an orUPDATE
. Note that unlikeusing_expression
, this is evaluated against the proposed new contentsof the row.
- Create a permissive policy.
- Create a restricive policy.
- Create a policy with a
CHECK
condition for inserts.