---
title: "ALTER TYPE"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/ddl_alter_type/"
---

# ALTER TYPE

Use the ALTER TYPE statement to change the definition of a user-defined type.

## Synopsis

Use the `ALTER TYPE` statement to change the definition of a user-defined type, such as renaming the type, changing its owner or schema, adding or renaming the values of an enumerated type, or dropping an attribute of a composite type.

## Syntax

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-1)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-1)

```output.ebnf
alter_type_rename ::= ALTER TYPE type_name RENAME TO new_name

alter_type_owner ::= ALTER TYPE type_name OWNER TO 
                     { new_owner
                       | CURRENT_ROLE
                       | CURRENT_USER
                       | SESSION_USER }

alter_type_set_schema ::= ALTER TYPE type_name SET SCHEMA schema_name

alter_type_rename_value ::= ALTER TYPE type_name RENAME VALUE 
                            existing_enum_value TO new_enum_value

alter_type_add_value ::= ALTER TYPE type_name ADD VALUE 
                         [ IF NOT EXISTS ] new_enum_value 
                         [ { BEFORE | AFTER } existing_enum_value ]

alter_type_drop_attribute ::= ALTER TYPE type_name 
                              drop_attribute_action [ , ... ]
```

#### alter\_type\_rename

ALTERTYPE[type\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#type-name)RENAMETO[new\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#new-name)

#### alter\_type\_owner

ALTERTYPE[type\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#type-name)OWNERTO[new\_owner](/stable/api/ysql/syntax_resources/grammar_diagrams#new-owner)CURRENT\_ROLECURRENT\_USERSESSION\_USER

#### alter\_type\_set\_schema

ALTERTYPE[type\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#type-name)SETSCHEMA[schema\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#schema-name)

#### alter\_type\_rename\_value

ALTERTYPE[type\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#type-name)RENAMEVALUE[existing\_enum\_value](/stable/api/ysql/syntax_resources/grammar_diagrams#existing-enum-value)TO[new\_enum\_value](/stable/api/ysql/syntax_resources/grammar_diagrams#new-enum-value)

#### alter\_type\_add\_value

ALTERTYPE[type\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#type-name)ADDVALUEIFNOTEXISTS[new\_enum\_value](/stable/api/ysql/syntax_resources/grammar_diagrams#new-enum-value)BEFOREAFTER[existing\_enum\_value](/stable/api/ysql/syntax_resources/grammar_diagrams#existing-enum-value)

#### alter\_type\_drop\_attribute

ALTERTYPE[type\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#type-name),[drop\_attribute\_action](/stable/api/ysql/syntax_resources/grammar_diagrams#drop-attribute-action)

## Semantics

### RENAME TO

Change the name of the type. Columns and other objects that use the type continue to work; they refer to the type by its new name.

### OWNER TO

Change the owner of the type. You must be a member of the new owning role to make this change.

### SET SCHEMA

Move the type to a different schema.

### RENAME VALUE

Rename a value of an enumerated type. An error is raised if `existing_enum_value` is not a value of the type, or if `new_enum_value` already is.

### ADD VALUE

Add a new value to an enumerated type. Use `BEFORE` or `AFTER` to place the new value at a specific position in the enum's sort ordering; by default the new value is added at the end. If `IF NOT EXISTS` is specified and the value already exists, a notice is issued instead of an error.

### DROP ATTRIBUTE

`DROP ATTRIBUTE` is supported in v2026.1.1.0+ and v2025.2.5.0+.

Drop an attribute from a composite type. If `IF EXISTS` is specified and the attribute does not exist, a notice is issued instead of an error. You can drop multiple attributes in a single statement by separating the `DROP ATTRIBUTE` actions with commas.

## Limitations

- `ALTER TYPE ... ADD ATTRIBUTE`, `ALTER TYPE ... ALTER ATTRIBUTE ... TYPE`, and `ALTER TYPE ... RENAME ATTRIBUTE` are not supported. See issue [#1893](https://github.com/yugabyte/yugabyte-db/issues/1893 "#1893").
- `ALTER TYPE ... DROP ATTRIBUTE ... CASCADE` is not supported when the type is used by a typed table (a table created with `CREATE TABLE ... OF type_name`). See issue [#30577](https://github.com/yugabyte/yugabyte-db/issues/30577 "#30577").
  
  ```sql
  CREATE TYPE two_ints AS (a int, b int);
  CREATE TABLE typed_tbl OF two_ints;
  ALTER TYPE two_ints DROP ATTRIBUTE b CASCADE;
  ```
  
  ```output
  ERROR:  drop attribute on the type of a typed table is not supported yet
  ```

## Examples

Rename a type.

```plpgsql
yugabyte=# CREATE TYPE feature_enum AS ENUM ('one', 'two', 'three');
yugabyte=# ALTER TYPE feature_enum RENAME TO feature_list;
```

Add and rename enum values.

```plpgsql
yugabyte=# ALTER TYPE feature_list ADD VALUE 'four' AFTER 'three';
yugabyte=# ALTER TYPE feature_list RENAME VALUE 'one' TO 'first';
```

Move a type to a different schema.

```plpgsql
yugabyte=# CREATE SCHEMA features;
yugabyte=# ALTER TYPE feature_list SET SCHEMA features;
```

Drop an attribute of a composite type.

```plpgsql
yugabyte=# CREATE TYPE feature_struct AS (id INTEGER, name TEXT);
yugabyte=# ALTER TYPE feature_struct DROP ATTRIBUTE name;
```

```plpgsql
yugabyte=# \d feature_struct
```

```output
      Composite type "public.feature_struct"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 id     | integer |           |          |
```

## See also

- [CREATE TYPE](/stable/api/ysql/the-sql-language/statements/ddl_create_type "CREATE TYPE")
- [DROP TYPE](/stable/api/ysql/the-sql-language/statements/ddl_drop_type "DROP TYPE")
