|
| 1 | +<!-- |
| 2 | +doc/src/sgml/ref/alter_variable.sgml |
| 3 | +PostgreSQL documentation |
| 4 | +--> |
| 5 | + |
| 6 | +<refentry id="sql-altervariable"> |
| 7 | + <indexterm zone="sql-altervariable"> |
| 8 | + <primary>ALTER VARIABLE</primary> |
| 9 | + </indexterm> |
| 10 | + |
| 11 | + <indexterm> |
| 12 | + <primary>session variable</primary> |
| 13 | + <secondary>altering</secondary> |
| 14 | + </indexterm> |
| 15 | + |
| 16 | + <refmeta> |
| 17 | + <refentrytitle>ALTER VARIABLE</refentrytitle> |
| 18 | + <manvolnum>7</manvolnum> |
| 19 | + <refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 20 | + </refmeta> |
| 21 | + |
| 22 | + <refnamediv> |
| 23 | + <refname>ALTER VARIABLE</refname> |
| 24 | + <refpurpose> |
| 25 | + change the definition of a session variable |
| 26 | + </refpurpose> |
| 27 | + </refnamediv> |
| 28 | + |
| 29 | + <refsynopsisdiv> |
| 30 | +<synopsis> |
| 31 | +ALTER VARIABLE <replaceable class="parameter">name</replaceable> OWNER TO { <replaceable class="parameter">new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER } |
| 32 | +ALTER VARIABLE <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable> |
| 33 | +ALTER VARIABLE <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable> |
| 34 | +</synopsis> |
| 35 | + </refsynopsisdiv> |
| 36 | + |
| 37 | + <refsect1> |
| 38 | + <title>Description</title> |
| 39 | + |
| 40 | + <para> |
| 41 | + The <command>ALTER VARIABLE</command> command changes the definition of an |
| 42 | + existing session variable. There are several subforms: |
| 43 | + |
| 44 | + <variablelist> |
| 45 | + <varlistentry> |
| 46 | + <term><literal>OWNER</literal></term> |
| 47 | + <listitem> |
| 48 | + <para> |
| 49 | + This form changes the owner of the session variable. |
| 50 | + </para> |
| 51 | + </listitem> |
| 52 | + </varlistentry> |
| 53 | + |
| 54 | + <varlistentry> |
| 55 | + <term><literal>RENAME</literal></term> |
| 56 | + <listitem> |
| 57 | + <para> |
| 58 | + This form changes the name of the session variable. |
| 59 | + </para> |
| 60 | + </listitem> |
| 61 | + </varlistentry> |
| 62 | + |
| 63 | + <varlistentry> |
| 64 | + <term><literal>SET SCHEMA</literal></term> |
| 65 | + <listitem> |
| 66 | + <para> |
| 67 | + This form moves the session variable into another schema. |
| 68 | + </para> |
| 69 | + </listitem> |
| 70 | + </varlistentry> |
| 71 | + |
| 72 | + </variablelist> |
| 73 | + </para> |
| 74 | + |
| 75 | + <para> |
| 76 | + Only the owner or a superuser is allowed to alter a session variable. |
| 77 | + In order to move a session variable from one schema to another, the user |
| 78 | + must also have the <literal>CREATE</literal> privilege on the new schema (or |
| 79 | + be a superuser). |
| 80 | + |
| 81 | + In order to move the session variable ownership from one role to another, |
| 82 | + the user must also be a direct or indirect member of the new |
| 83 | + owning role, and that role must have the <literal>CREATE</literal> privilege |
| 84 | + on the session variable's schema (or be a superuser). These restrictions |
| 85 | + enforce that altering the owner doesn't do anything you couldn't do by |
| 86 | + dropping and recreating the session variable. |
| 87 | + </para> |
| 88 | + </refsect1> |
| 89 | + |
| 90 | + <refsect1> |
| 91 | + <title>Parameters</title> |
| 92 | + |
| 93 | + <para> |
| 94 | + <variablelist> |
| 95 | + <varlistentry> |
| 96 | + <term><replaceable class="parameter">name</replaceable></term> |
| 97 | + <listitem> |
| 98 | + <para> |
| 99 | + The name (possibly schema-qualified) of the existing session variable |
| 100 | + to alter. |
| 101 | + </para> |
| 102 | + </listitem> |
| 103 | + </varlistentry> |
| 104 | + |
| 105 | + <varlistentry> |
| 106 | + <term><replaceable class="parameter">new_owner</replaceable></term> |
| 107 | + <listitem> |
| 108 | + <para> |
| 109 | + The user name of the new owner of the session variable. |
| 110 | + </para> |
| 111 | + </listitem> |
| 112 | + </varlistentry> |
| 113 | + |
| 114 | + <varlistentry> |
| 115 | + <term><replaceable class="parameter">new_name</replaceable></term> |
| 116 | + <listitem> |
| 117 | + <para> |
| 118 | + The new name for the session variable. |
| 119 | + </para> |
| 120 | + </listitem> |
| 121 | + </varlistentry> |
| 122 | + |
| 123 | + <varlistentry> |
| 124 | + <term><replaceable class="parameter">new_schema</replaceable></term> |
| 125 | + <listitem> |
| 126 | + <para> |
| 127 | + The new schema for the session variable. |
| 128 | + </para> |
| 129 | + </listitem> |
| 130 | + </varlistentry> |
| 131 | + </variablelist> |
| 132 | + </para> |
| 133 | + </refsect1> |
| 134 | + |
| 135 | + <refsect1> |
| 136 | + <title>Examples</title> |
| 137 | + |
| 138 | + <para> |
| 139 | + To rename a session variable: |
| 140 | +<programlisting> |
| 141 | +ALTER VARIABLE foo RENAME TO boo; |
| 142 | +</programlisting> |
| 143 | + </para> |
| 144 | + |
| 145 | + <para> |
| 146 | + To change the owner of the session variable <literal>boo</literal> to |
| 147 | + <literal>joe</literal>: |
| 148 | +<programlisting> |
| 149 | +ALTER VARIABLE boo OWNER TO joe; |
| 150 | +</programlisting> |
| 151 | + </para> |
| 152 | + |
| 153 | + <para> |
| 154 | + To change the schema of the session variable <literal>boo</literal> to |
| 155 | + <literal>private</literal>: |
| 156 | +<programlisting> |
| 157 | +ALTER VARIABLE boo SET SCHEMA private; |
| 158 | +</programlisting> |
| 159 | + </para> |
| 160 | + </refsect1> |
| 161 | + |
| 162 | + <refsect1> |
| 163 | + <title>Compatibility</title> |
| 164 | + |
| 165 | + <para> |
| 166 | + Session variables and this command in particular are a PostgreSQL extension. |
| 167 | + </para> |
| 168 | + </refsect1> |
| 169 | + |
| 170 | + <refsect1 id="sql-altervariable-see-also"> |
| 171 | + <title>See Also</title> |
| 172 | + |
| 173 | + <simplelist type="inline"> |
| 174 | + <member><xref linkend="sql-createvariable"/></member> |
| 175 | + <member><xref linkend="sql-dropvariable"/></member> |
| 176 | + </simplelist> |
| 177 | + </refsect1> |
| 178 | +</refentry> |
0 commit comments