RefLib

Reference library for AI

Back

postgresql_16:7.1.40.4 Examples

PostgreSQL 16 > Reference > SQL Commands > ALTER TYPE > 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 );

Back