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 is PUBLIC which applies thepolicy to all roles.
  • check_expression is a SQL conditional expression that is used only for INSERT and UPDATEqueries. Only rows for which the expression evaluates to true will be allowed in an orUPDATE. Note that unlike using_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.