PostgreSQL INSERT into an array of enums

前端 未结 4 1880
萌比男神i
萌比男神i 2021-02-13 02:48

How can I insert an array of enums?
Here is my enum:

CREATE TYPE equipment AS ENUM (\'projector\',\'PAsystem\',\'safe\',\'PC\',\'ph         


        
4条回答
  •  春和景丽
    2021-02-13 03:18

    PostgreSQL doesn't know how to automatically cast input of type text to input of type equipment. You have to explicitly declare your strings as being of type equipment:

    ARRAY['projector','PAsystem','safe']::equipment[]
    

    I confirmed this with SQL Fiddle.

提交回复
热议问题