| --- |
| title: REASSIGN OWNED |
| --- |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| Changes the ownership of database objects owned by a database role. |
| |
| ## <a id="topic1__section2"></a>Synopsis |
| |
| ``` pre |
| REASSIGN OWNED BY <old_role> [, ...] TO <new_role> |
| |
| ``` |
| |
| ## <a id="topic1__section3"></a>Description |
| |
| `REASSIGN OWNED` reassigns all the objects in the current database that are owned by \<old\_role\> to \<new\_role\>. Note that it does not change the ownership of the database itself. |
| |
| ## <a id="topic1__section4"></a>Parameters |
| |
| <dt> \<old\_role\> </dt> |
| <dd>The name of a role. The ownership of all the objects in the current database owned by this role will be reassigned to \<new\_role\>.</dd> |
| |
| <dt> \<new\_role\> </dt> |
| <dd>The name of the role that will be made the new owner of the affected objects.</dd> |
| |
| ## <a id="topic1__section5"></a>Notes |
| |
| `REASSIGN OWNED` is often used to prepare for the removal of one or more roles. Because `REASSIGN OWNED` 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. |
| |
| The `DROP OWNED` command is an alternative that drops all the database objects owned by one or more roles. |
| |
| The `REASSIGN OWNED` command does not affect the privileges granted to the old roles in objects that are not owned by them. Use `DROP OWNED` to revoke those privileges. |
| |
| ## <a id="topic1__section6"></a>Examples |
| |
| Reassign any database objects owned by the role named `sally` and `bob` to `admin`; |
| |
| ``` pre |
| REASSIGN OWNED BY sally, bob TO admin; |
| ``` |
| |
| ## <a id="topic1__section7"></a>Compatibility |
| |
| The `REASSIGN OWNED` statement is a HAWQ extension. |
| |
| ## <a id="topic1__section8"></a>See Also |
| |
| [DROP OWNED](DROP-OWNED.html), [DROP ROLE](DROP-ROLE.html) |