1<!-- 2doc/src/sgml/ref/reassign_owned.sgml 3PostgreSQL documentation 4--> 5 6<refentry id="sql-reassign-owned"> 7 <indexterm zone="sql-reassign-owned"> 8 <primary>REASSIGN OWNED</primary> 9 </indexterm> 10 11 <refmeta> 12 <refentrytitle>REASSIGN OWNED</refentrytitle> 13 <manvolnum>7</manvolnum> 14 <refmiscinfo>SQL - Language Statements</refmiscinfo> 15 </refmeta> 16 17 <refnamediv> 18 <refname>REASSIGN OWNED</refname> 19 <refpurpose>change the ownership of database objects owned by a database role</refpurpose> 20 </refnamediv> 21 22 <refsynopsisdiv> 23<synopsis> 24REASSIGN OWNED BY { <replaceable class="parameter">old_role</replaceable> | CURRENT_USER | SESSION_USER } [, ...] 25 TO { <replaceable class="parameter">new_role</replaceable> | CURRENT_USER | SESSION_USER } 26</synopsis> 27 </refsynopsisdiv> 28 29 <refsect1> 30 <title>Description</title> 31 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> 39 40 <refsect1> 41 <title>Parameters</title> 42 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> 55 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> 67 68 <refsect1> 69 <title>Notes</title> 70 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> 78 79 <para> 80 <command>REASSIGN OWNED</command> requires membership on both the 81 source role(s) and the target role. 82 </para> 83 84 <para> 85 The <xref linkend="sql-drop-owned"/> command is an alternative that 86 simply drops all the database objects owned by one or more roles. 87 </para> 88 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> 97 98 <para> 99 See <xref linkend="role-removal"/> for more discussion. 100 </para> 101 102 </refsect1> 103 104 <refsect1> 105 <title>Compatibility</title> 106 107 <para> 108 The <command>REASSIGN OWNED</command> command is a 109 <productname>PostgreSQL</productname> extension. 110 </para> 111 </refsect1> 112 113 <refsect1> 114 <title>See Also</title> 115 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> 122 123</refentry> 124