ALTER TYPE

Function

ALTER TYPE modifies the definition of a type.

Syntax

Parameter Description

Examples

Create an example composite type test, enumeration type testdata, and user user_t.

1
2
3
CREATE TYPE test AS (col1 int, col text);
CREATE TYPE testdata AS ENUM ('create', 'modify', 'closed');
CREATE USER user_t PASSWORD '{Password}';

Rename the data type.

1
ALTER TYPE test RENAME TO test1;

Change the owner of the user-defined type test1 to user_t.

1
ALTER TYPE test1 OWNER TO user_t;

Change the schema of the user-defined type test1 to user_t.

1
ALTER TYPE test1 SET SCHEMA user_t;

Add the f3 attribute to the test1 data type.

1
ALTER TYPE user_t.test1 ADD ATTRIBUTE col3 int;

Add a tag value to the enumeration type testdata.

1
ALTER TYPE testdata ADD VALUE IF NOT EXISTS 'regress' BEFORE 'closed';

Rename a tag value of the enumeration type testdata.

1
ALTER TYPE testdata RENAME VALUE 'create' TO 'new';

Helpful Links

CREATE TYPE, DROP TYPE