PostgreSQL INSERT into an array of enums

前端 未结 4 1864
萌比男神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:17

    The alternative to an ARRAY constructor like @Mark correctly supplied is to cast a string literal directly:

    '{projector,PAsystem,safe}'::equipment[]
    

    This variant is shorter and some clients have problems with the ARRAY constructor, which is a function-like element.

提交回复
热议问题