CREATE TYPE creates a new type in a . After the type is created, it can only be referenced from the database that contains the type.
The following user-defined data types can be created with this statement:
The “ statement performs a schema change. For more information about how online schema changes work in CockroachDB, see .
Synopsis
Parameters
| Parameter | Description |
|---|---|
type_name | The name of the type. You can qualify the name with a (e.g., db.typename), but after the type is created, it can only be referenced from the database that contains the type. |
IF NOT EXISTS | Create a new type only if a type of the same name does not already exist in the database; if one does exist, do not return an error. |
opt_enum_val_list | A list of values that make up the type’s enumerated set. |
opt_composite_type_list | A list of values that make up the set of types that make up a composite type. |
Required privileges
- To create a type, the user must have on the parent database and the schema in which the type is being created.
- To use a user-defined type in a table (e.g., when defining a column’s type), the user must have on the type.
Example
Create an enumerated data type
Use the statements below to create an data type.Create a composite data type
Use the statements below to create a composite data type:mypoint:

