ALTER TYPE statement modifies a user-defined data type in the current database.
The ALTER TYPE statement performs a schema change. For more information about how online schema changes work in CockroachDB, see Online Schema Changes.
You can only cancel
ALTER TYPE schema change jobs that drop values. This is because when you drop a value, CockroachDB searches through every row that could contain the type’s value, which could take a long time.All other ALTER TYPE schema change jobs are non-cancellable.Synopsis
Parameters
Required privileges
- To alter a type, the user must be the owner of the type.
- To set the schema of a user-defined type, the user must have the
CREATEprivilege on the schema and theDROPprivilege on the type. - To alter the owner of a user-defined type:
- The user executing the command must be a member of the new owner role.
- The new owner role must have the
CREATEprivilege on the schema the type belongs to.
Known limitations
- You can only reference a user-defined type from the database that contains the type.
Example
The following example uses a user-defined type.Add a value to a user-defined type
To add a value to thestatus type, use an ADD VALUE clause:
Rename a value in a user-defined type
To rename a value in thestatus type, use a RENAME VALUE clause:
Rename a user-defined type
To rename thestatus type, use a RENAME TO clause:
Drop a value in a user-defined type
To drop a value from theaccount_status type, use a DROP VALUE clause:

