blob: 90e829c61f2019c30897d5665412c25da68ce446 (
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
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>REASSIGN OWNED</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-prepare-transaction.html" title="PREPARE TRANSACTION" /><link rel="next" href="sql-refreshmaterializedview.html" title="REFRESH MATERIALIZED VIEW" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">REASSIGN OWNED</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-prepare-transaction.html" title="PREPARE TRANSACTION">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-refreshmaterializedview.html" title="REFRESH MATERIALIZED VIEW">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-REASSIGN-OWNED"><div class="titlepage"></div><a id="id-1.9.3.161.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">REASSIGN OWNED</span></h2><p>REASSIGN OWNED — change the ownership of database objects owned by a database role</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
REASSIGN OWNED BY { <em class="replaceable"><code>old_role</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]
TO { <em class="replaceable"><code>new_role</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
</pre></div><div class="refsect1" id="id-1.9.3.161.5"><h2>Description</h2><p>
<code class="command">REASSIGN OWNED</code> instructs the system to change
the ownership of database objects owned by any of the
<em class="replaceable"><code>old_roles</code></em> to
<em class="replaceable"><code>new_role</code></em>.
</p></div><div class="refsect1" id="id-1.9.3.161.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>old_role</code></em></span></dt><dd><p>
The name of a role. The ownership of all the objects within the
current database, and of all shared objects (databases, tablespaces),
owned by this role will be reassigned to
<em class="replaceable"><code>new_role</code></em>.
</p></dd><dt><span class="term"><em class="replaceable"><code>new_role</code></em></span></dt><dd><p>
The name of the role that will be made the new owner of the
affected objects.
</p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.161.7"><h2>Notes</h2><p>
<code class="command">REASSIGN OWNED</code> is often used to prepare for the
removal of one or more roles. Because <code class="command">REASSIGN
OWNED</code> does not affect objects within other databases,
it is usually necessary to execute this command in each database
that contains objects owned by a role that is to be removed.
</p><p>
<code class="command">REASSIGN OWNED</code> requires membership on both the
source role(s) and the target role.
</p><p>
The <a class="link" href="sql-drop-owned.html" title="DROP OWNED"><code class="command">DROP OWNED</code></a> command is an alternative that
simply drops all the database objects owned by one or more roles.
</p><p>
The <code class="command">REASSIGN OWNED</code> command does not affect any
privileges granted to
the <em class="replaceable"><code>old_roles</code></em> on objects
that are not owned by them. Likewise, it does not affect default
privileges created with <code class="command">ALTER DEFAULT PRIVILEGES</code>.
Use <code class="command">DROP OWNED</code> to revoke such privileges.
</p><p>
See <a class="xref" href="role-removal.html" title="22.4. Dropping Roles">Section 22.4</a> for more discussion.
</p></div><div class="refsect1" id="id-1.9.3.161.8"><h2>Compatibility</h2><p>
The <code class="command">REASSIGN OWNED</code> command is a
<span class="productname">PostgreSQL</span> extension.
</p></div><div class="refsect1" id="id-1.9.3.161.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-drop-owned.html" title="DROP OWNED"><span class="refentrytitle">DROP OWNED</span></a>, <a class="xref" href="sql-droprole.html" title="DROP ROLE"><span class="refentrytitle">DROP ROLE</span></a>, <a class="xref" href="sql-alterdatabase.html" title="ALTER DATABASE"><span class="refentrytitle">ALTER DATABASE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-prepare-transaction.html" title="PREPARE TRANSACTION">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-refreshmaterializedview.html" title="REFRESH MATERIALIZED VIEW">Next</a></td></tr><tr><td width="40%" align="left" valign="top">PREPARE TRANSACTION </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="40%" align="right" valign="top"> REFRESH MATERIALIZED VIEW</td></tr></table></div></body></html>
|