Skip to content

Instantly share code, notes, and snippets.

@s7anley
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s7anley/9068191 to your computer and use it in GitHub Desktop.
Save s7anley/9068191 to your computer and use it in GitHub Desktop.
Update Enum Type Item (Label) in PostgreSQL
-- Update one label in custom enum type
UPDATE pg_enum SET enumlabel = 'new_value'
WHERE enumlabel = 'old_value' AND enumtypid = (
SELECT oid FROM pg_type WHERE typname = 'enum_type'
);
-- Add new label in custom type avaliable since PostgreSQL 9.1
ALTER TYPE enum_type ADD VALUE 'new_value' BEFORE 'old_value';
ALTER TYPE enum_type ADD VALUE 'new_value' AFTER 'old_value';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment