1<!--
2doc/src/sgml/ref/alter_policy.sgml
3PostgreSQL documentation
4-->
5
6<refentry id="sql-alterpolicy">
7 <indexterm zone="sql-alterpolicy">
8  <primary>ALTER POLICY</primary>
9 </indexterm>
10
11 <refmeta>
12  <refentrytitle>ALTER POLICY</refentrytitle>
13  <manvolnum>7</manvolnum>
14  <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
16
17 <refnamediv>
18  <refname>ALTER POLICY</refname>
19  <refpurpose>change the definition of a row level security policy</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23<synopsis>
24ALTER POLICY <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table_name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
25
26ALTER POLICY <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table_name</replaceable>
27    [ TO { <replaceable class="parameter">role_name</replaceable> | PUBLIC | CURRENT_USER | SESSION_USER } [, ...] ]
28    [ USING ( <replaceable class="parameter">using_expression</replaceable> ) ]
29    [ WITH CHECK ( <replaceable class="parameter">check_expression</replaceable> ) ]
30</synopsis>
31 </refsynopsisdiv>
32
33 <refsect1>
34  <title>Description</title>
35
36  <para>
37   <command>ALTER POLICY</command> changes the definition of an existing
38   row-level security policy.  Note that <command>ALTER POLICY</command>
39   only allows the set of roles to which the policy applies and the
40   <literal>USING</literal> and <literal>WITH CHECK</literal> expressions to
41   be modified.  To change other properties of a policy, such as the command
42   to which it applies or whether it is permissive or restrictive, the policy
43   must be dropped and recreated.
44  </para>
45
46  <para>
47   To use <command>ALTER POLICY</command>, you must own the table that
48   the policy applies to.
49  </para>
50
51  <para>
52   In the second form of <command>ALTER POLICY</command>, the role list,
53   <replaceable class="parameter">using_expression</replaceable>, and
54   <replaceable class="parameter">check_expression</replaceable> are replaced
55   independently if specified.  When one of those clauses is omitted, the
56   corresponding part of the policy is unchanged.
57  </para>
58 </refsect1>
59
60 <refsect1>
61  <title>Parameters</title>
62
63  <variablelist>
64   <varlistentry>
65    <term><replaceable class="parameter">name</replaceable></term>
66    <listitem>
67     <para>
68      The name of an existing policy to alter.
69     </para>
70    </listitem>
71   </varlistentry>
72
73   <varlistentry>
74    <term><replaceable class="parameter">table_name</replaceable></term>
75    <listitem>
76     <para>
77      The name (optionally schema-qualified) of the table that the
78      policy is on.
79     </para>
80    </listitem>
81   </varlistentry>
82
83   <varlistentry>
84    <term><replaceable class="parameter">new_name</replaceable></term>
85    <listitem>
86     <para>
87      The new name for the policy.
88     </para>
89    </listitem>
90   </varlistentry>
91
92   <varlistentry>
93    <term><replaceable class="parameter">role_name</replaceable></term>
94    <listitem>
95     <para>
96      The role(s) to which the policy applies.  Multiple roles can be
97      specified at one time.  To apply the policy to all roles,
98      use <literal>PUBLIC</literal>.
99     </para>
100    </listitem>
101   </varlistentry>
102
103   <varlistentry>
104    <term><replaceable class="parameter">using_expression</replaceable></term>
105    <listitem>
106     <para>
107      The <literal>USING</literal> expression for the policy.
108      See <xref linkend="sql-createpolicy"/> for details.
109     </para>
110    </listitem>
111   </varlistentry>
112
113   <varlistentry>
114    <term><replaceable class="parameter">check_expression</replaceable></term>
115    <listitem>
116     <para>
117      The <literal>WITH CHECK</literal> expression for the policy.
118      See <xref linkend="sql-createpolicy"/> for details.
119     </para>
120    </listitem>
121   </varlistentry>
122
123  </variablelist>
124 </refsect1>
125
126 <refsect1>
127  <title>Compatibility</title>
128
129  <para>
130   <command>ALTER POLICY</command> is a <productname>PostgreSQL</productname> extension.
131  </para>
132 </refsect1>
133
134 <refsect1>
135  <title>See Also</title>
136
137  <simplelist type="inline">
138   <member><xref linkend="sql-createpolicy"/></member>
139   <member><xref linkend="sql-droppolicy"/></member>
140  </simplelist>
141 </refsect1>
142
143</refentry>
144