blob: 2350b81c89d11c11696ff65440214b50a49a0c97 [file] [log] [blame]
---
title: ALTER TYPE
---
<!--
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 definition of a data type.
## <a id="synopsis"></a>Synopsis
``` pre
ALTER TYPE <name>
   OWNER TO <new_owner> | SET SCHEMA <new_schema>
```
## <a id="desc"></a>Description
 `ALTER TYPE` changes the definition of an existing type. You can change the owner and the schema of a type.
You must own the type to use `ALTER TYPE`. To change the schema of a type, you must also have `CREATE` privilege on the new schema. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have `CREATE` privilege on the type's schema. (These restrictions enforce that altering the owner does not do anything that could be done by dropping and recreating the type. However, a superuser can alter ownership of any type.)
## <a id="altertype__section4"></a>Parameters
<dt> \<name\> </dt>
<dd>The name (optionally schema-qualified) of an existing type to alter.</dd>
<dt> \<new\_owner\> </dt>
<dd>The user name of the new owner of the type.</dd>
<dt> \<new\_schema\> </dt>
<dd>The new schema for the type.</dd>
## <a id="altertype__section5"></a>Examples
To change the owner of the user-defined type `email` to `joe`:
``` pre
ALTER TYPE email OWNER TO joe;
```
To change the schema of the user-defined type `email` to `customers`:
``` pre
ALTER TYPE email SET SCHEMA customers;
```
## <a id="altertype__section6"></a>Compatibility
There is no `ALTER TYPE` statement in the SQL standard.
## <a id="see"></a>See Also
[CREATE TYPE](CREATE-TYPE.html), [DROP TYPE](DROP-TYPE.html)