Last active
August 29, 2015 13:56
-
-
Save s7anley/9068191 to your computer and use it in GitHub Desktop.
Update Enum Type Item (Label) in PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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