doc: ALTER DEFAULT PRIVILEGES does not affect inherited roles
[pgsql.git] / doc / src / sgml / ref / reassign_owned.sgml
blobab692bd06908b34334a75790739b667e0dc35c98
1 <!--
2 doc/src/sgml/ref/reassign_owned.sgml
3 PostgreSQL documentation
4 -->
6 <refentry id="sql-reassign-owned">
7 <indexterm zone="sql-reassign-owned">
8 <primary>REASSIGN OWNED</primary>
9 </indexterm>
11 <refmeta>
12 <refentrytitle>REASSIGN OWNED</refentrytitle>
13 <manvolnum>7</manvolnum>
14 <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
17 <refnamediv>
18 <refname>REASSIGN OWNED</refname>
19 <refpurpose>change the ownership of database objects owned by a database role</refpurpose>
20 </refnamediv>
22 <refsynopsisdiv>
23 <synopsis>
24 REASSIGN OWNED BY { <replaceable class="parameter">old_role</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]
25 TO { <replaceable class="parameter">new_role</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
26 </synopsis>
27 </refsynopsisdiv>
29 <refsect1>
30 <title>Description</title>
32 <para>
33 <command>REASSIGN OWNED</command> instructs the system to change
34 the ownership of database objects owned by any of the
35 <replaceable class="parameter">old_roles</replaceable> to
36 <replaceable class="parameter">new_role</replaceable>.
37 </para>
38 </refsect1>
40 <refsect1>
41 <title>Parameters</title>
43 <variablelist>
44 <varlistentry>
45 <term><replaceable class="parameter">old_role</replaceable></term>
46 <listitem>
47 <para>
48 The name of a role. The ownership of all the objects within the
49 current database, and of all shared objects (databases, tablespaces),
50 owned by this role will be reassigned to
51 <replaceable class="parameter">new_role</replaceable>.
52 </para>
53 </listitem>
54 </varlistentry>
56 <varlistentry>
57 <term><replaceable class="parameter">new_role</replaceable></term>
58 <listitem>
59 <para>
60 The name of the role that will be made the new owner of the
61 affected objects.
62 </para>
63 </listitem>
64 </varlistentry>
65 </variablelist>
66 </refsect1>
68 <refsect1>
69 <title>Notes</title>
71 <para>
72 <command>REASSIGN OWNED</command> is often used to prepare for the
73 removal of one or more roles. Because <command>REASSIGN
74 OWNED</command> does not affect objects within other databases,
75 it is usually necessary to execute this command in each database
76 that contains objects owned by a role that is to be removed.
77 </para>
79 <para>
80 <command>REASSIGN OWNED</command> requires membership on both the
81 source role(s) and the target role.
82 </para>
84 <para>
85 The <link linkend="sql-drop-owned"><command>DROP OWNED</command></link> command is an alternative that
86 simply drops all the database objects owned by one or more roles.
87 </para>
89 <para>
90 The <command>REASSIGN OWNED</command> command does not affect any
91 privileges granted to
92 the <replaceable class="parameter">old_roles</replaceable> on objects
93 that are not owned by them. Likewise, it does not affect default
94 privileges created with <command>ALTER DEFAULT PRIVILEGES</command>.
95 Use <command>DROP OWNED</command> to revoke such privileges.
96 </para>
98 <para>
99 See <xref linkend="role-removal"/> for more discussion.
100 </para>
102 </refsect1>
104 <refsect1>
105 <title>Compatibility</title>
107 <para>
108 The <command>REASSIGN OWNED</command> command is a
109 <productname>PostgreSQL</productname> extension.
110 </para>
111 </refsect1>
113 <refsect1>
114 <title>See Also</title>
116 <simplelist type="inline">
117 <member><xref linkend="sql-drop-owned"/></member>
118 <member><xref linkend="sql-droprole"/></member>
119 <member><xref linkend="sql-alterdatabase"/></member>
120 </simplelist>
121 </refsect1>
123 </refentry>