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