# phpman > man > ALTER_TYPE(7)

ALTER [TYPE(7)](https://www.chedong.com/phpMan.php/man/TYPE/7/markdown)                      PostgreSQL 14.23 Documentation                      ALTER [TYPE(7)](https://www.chedong.com/phpMan.php/man/TYPE/7/markdown)



## NAME
       ALTER_TYPE - change the definition of a type

## SYNOPSIS
       ALTER TYPE _name_ OWNER TO { _new_owner_ | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
       ALTER TYPE _name_ RENAME TO _new_name_
       ALTER TYPE _name_ SET SCHEMA _new_schema_
       ALTER TYPE _name_ RENAME ATTRIBUTE _attribute_name_ TO _new_attribute_name_ [ CASCADE | RESTRICT ]
       ALTER TYPE _name_ _action_ [, ... ]
       ALTER TYPE _name_ ADD VALUE [ IF NOT EXISTS ] _new_enum_value_ [ { BEFORE | AFTER } _neighbor_enum_value_ ]
       ALTER TYPE _name_ RENAME VALUE _existing_enum_value_ TO _new_enum_value_
       ALTER TYPE _name_ SET ( _property_ = _value_ [, ... ] )

       where _action_ is one of:

           ADD ATTRIBUTE _attribute_name_ _data_type_ [ COLLATE _collation_ ] [ CASCADE | RESTRICT ]
           DROP ATTRIBUTE [ IF EXISTS ] _attribute_name_ [ CASCADE | RESTRICT ]
           ALTER ATTRIBUTE _attribute_name_ [ SET DATA ] TYPE _data_type_ [ COLLATE _collation_ ] [ CASCADE | RESTRICT ]

## DESCRIPTION
       **ALTER** **TYPE** changes the definition of an existing type. There are several subforms:

       OWNER
           This form changes the owner of the type.

       RENAME
           This form changes the name of the type.

       SET SCHEMA
           This form moves the type into another schema.

       RENAME ATTRIBUTE
           This form is only usable with composite types. It changes the name of an individual
           attribute of the type.

       ADD ATTRIBUTE
           This form adds a new attribute to a composite type, using the same syntax as **CREATE** **TYPE**.

       DROP ATTRIBUTE [ IF EXISTS ]
           This form drops an attribute from a composite type. If IF EXISTS is specified and the
           attribute does not exist, no error is thrown. In this case a notice is issued instead.

       ALTER ATTRIBUTE ... SET DATA TYPE
           This form changes the type of an attribute of a composite type.

       ADD VALUE [ IF NOT EXISTS ] [ BEFORE | AFTER ]
           This form adds a new value to an enum type. The new value's place in the enum's ordering
           can be specified as being BEFORE or AFTER one of the existing values. Otherwise, the new
           item is added at the end of the list of values.

           If IF NOT EXISTS is specified, it is not an error if the type already contains the new
           value: a notice is issued but no other action is taken. Otherwise, an error will occur if
           the new value is already present.

       RENAME VALUE
           This form renames a value of an enum type. The value's place in the enum's ordering is
           not affected. An error will occur if the specified value is not present or the new name
           is already present.

       SET ( _property_ = _value_ [, ... ] )
           This form is only applicable to base types. It allows adjustment of a subset of the
           base-type properties that can be set in **CREATE** **TYPE**. Specifically, these properties can
           be changed:

           •   RECEIVE can be set to the name of a binary input function, or NONE to remove the
               type's binary input function. Using this option requires superuser privilege.

           •   SEND can be set to the name of a binary output function, or NONE to remove the type's
               binary output function. Using this option requires superuser privilege.

           •   TYPMOD_IN can be set to the name of a type modifier input function, or NONE to remove
               the type's type modifier input function. Using this option requires superuser
               privilege.

           •   TYPMOD_OUT can be set to the name of a type modifier output function, or NONE to
               remove the type's type modifier output function. Using this option requires superuser
               privilege.

           •   ANALYZE can be set to the name of a type-specific statistics collection function, or
               NONE to remove the type's statistics collection function. Using this option requires
               superuser privilege.

           •   SUBSCRIPT can be set to the name of a type-specific subscripting handler function, or
               NONE to remove the type's subscripting handler function. Using this option requires
               superuser privilege.

           •   STORAGE can be set to plain, extended, external, or main (see Section 70.2 for more
               information about what these mean). However, changing from plain to another setting
               requires superuser privilege (because it requires that the type's C functions all be
               TOAST-ready), and changing to plain from another setting is not allowed at all (since
               the type may already have TOASTed values present in the database). Note that changing
               this option doesn't by itself change any stored data, it just sets the default TOAST
               strategy to be used for table columns created in the future. See ALTER TABLE
               (**ALTER**___**[TABLE**(7)](https://www.chedong.com/phpMan.php/man/TABLE/7/markdown)) to change the TOAST strategy for existing table columns.

           See CREATE TYPE (**CREATE**___**[TYPE**(7)](https://www.chedong.com/phpMan.php/man/TYPE/7/markdown)) for more details about these type properties. Note that
           where appropriate, a change in these properties for a base type will be propagated
           automatically to domains based on that type.

       The ADD ATTRIBUTE, DROP ATTRIBUTE, and ALTER ATTRIBUTE actions can be combined into a list of
       multiple alterations to apply in parallel. For example, it is possible to add several
       attributes and/or alter the type of several attributes in a single command.

       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 doesn't do anything you couldn't do by
       dropping and recreating the type. However, a superuser can alter ownership of any type
       anyway.) To add an attribute or alter an attribute type, you must also have USAGE privilege
       on the attribute's data type.

## PARAMETERS
       _name_
           The name (possibly schema-qualified) of an existing type to alter.

       _new_name_
           The new name for the type.

       _new_owner_
           The user name of the new owner of the type.

       _new_schema_
           The new schema for the type.

       _attribute_name_
           The name of the attribute to add, alter, or drop.

       _new_attribute_name_
           The new name of the attribute to be renamed.

       _data_type_
           The data type of the attribute to add, or the new type of the attribute to alter.

       _new_enum_value_
           The new value to be added to an enum type's list of values, or the new name to be given
           to an existing value. Like all enum literals, it needs to be quoted.

       _neighbor_enum_value_
           The existing enum value that the new value should be added immediately before or after in
           the enum type's sort ordering. Like all enum literals, it needs to be quoted.

       _existing_enum_value_
           The existing enum value that should be renamed. Like all enum literals, it needs to be
           quoted.

       _property_
           The name of a base-type property to be modified; see above for possible values.

       CASCADE
           Automatically propagate the operation to typed tables of the type being altered, and
           their descendants.

       RESTRICT
           Refuse the operation if the type being altered is the type of a typed table. This is the
           default.

## NOTES
       If **ALTER** **TYPE** **...** **ADD** **VALUE** (the form that adds a new value to an enum type) is executed
       inside a transaction block, the new value cannot be used until after the transaction has been
       committed.

       Comparisons involving an added enum value will sometimes be slower than comparisons involving
       only original members of the enum type. This will usually only occur if BEFORE or AFTER is
       used to set the new value's sort position somewhere other than at the end of the list.
       However, sometimes it will happen even though the new value is added at the end (this occurs
       if the OID counter “wrapped around” since the original creation of the enum type). The
       slowdown is usually insignificant; but if it matters, optimal performance can be regained by
       dropping and recreating the enum type, or by dumping and restoring the database.

## EXAMPLES
       To rename a data type:

           ALTER TYPE electronic_mail RENAME TO email;

       To change the owner of the type email to joe:

           ALTER TYPE email OWNER TO joe;

       To change the schema of the type email to customers:

           ALTER TYPE email SET SCHEMA customers;

       To add a new attribute to a composite type:

           ALTER TYPE compfoo ADD ATTRIBUTE f3 int;

       To add a new value to an enum type in a particular sort position:

           ALTER TYPE colors ADD VALUE 'orange' AFTER 'red';

       To rename an enum value:

           ALTER TYPE colors RENAME VALUE 'purple' TO 'mauve';

       To create binary I/O functions for an existing base type:

           CREATE FUNCTION mytypesend(mytype) RETURNS bytea ...;
           CREATE FUNCTION mytyperecv(internal, oid, integer) RETURNS mytype ...;
           ALTER TYPE mytype SET (
               SEND = mytypesend,
               RECEIVE = mytyperecv
           );

## COMPATIBILITY
       The variants to add and drop attributes are part of the SQL standard; the other variants are
       PostgreSQL extensions.

## SEE ALSO
       CREATE TYPE (**CREATE**___**[TYPE**(7)](https://www.chedong.com/phpMan.php/man/TYPE/7/markdown)), DROP TYPE (**DROP**___**[TYPE**(7)](https://www.chedong.com/phpMan.php/man/TYPE/7/markdown))



PostgreSQL 14.23                                2026                                   ALTER [TYPE(7)](https://www.chedong.com/phpMan.php/man/TYPE/7/markdown)
