Adding a new value to an existing ENUM Type

前端 未结 18 1321
春和景丽
春和景丽 2020-12-04 04:52

I have a table column that uses an enum type. I wish to update that enum type to have an additional possible value. I don\'t want to delete any exi

18条回答
  •  执念已碎
    2020-12-04 05:24

    I can't seem to post a comment, so I'll just say that updating pg_enum works in Postgres 8.4 . For the way our enums are set up, I've added new values to existing enum types via:

    INSERT INTO pg_enum (enumtypid, enumlabel)
      SELECT typelem, 'NEWENUM' FROM pg_type WHERE
        typname = '_ENUMNAME_WITH_LEADING_UNDERSCORE';
    

    It's a little scary, but it makes sense given the way Postgres actually stores its data.

提交回复
热议问题