Empty array as PostgreSQL array column default value

前端 未结 2 1791
无人及你
无人及你 2021-02-01 12:13

I have a defined an array field in postgresql 9.4 database:

character varying(64)[]

Can I have an empty array e.g. {} for default value of that

2条回答
  •  孤街浪徒
    2021-02-01 12:48

    You need to use the explicit array initializer and cast that to the correct type:

    ALTER TABLE public.accounts 
        ALTER COLUMN pwd_history SET DEFAULT array[]::varchar[];
    

提交回复
热议问题