· 1 min read
#010

How to Add Value to Existing Enum in Postgres

programming backend sql postgres

Problem

We have an existing enum in Postgres and we want to add a new value to it. The existing enum looks like this:

CREATE TYPE gift_card_status_enum AS ENUM ('locked', 'unlocked');

The enum have two values locked and unlocked. We want to add a new value editing to it.

ALTER TYPE to Add New Value to Existing Enum

We could easily add a new value to the existing enum using ALTER TYPE command. Here is how we can do it:

ALTER TYPE gift_card_status_enum ADD VALUE 'editing';

If you enjoyed this post, consider subscribing.
Get my next post delivered to you.

All articles