Empty array as PostgreSQL array column default value

前端 未结 2 1790
无人及你
无人及你 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:45

    I tested both the accepted answer and the one from the comments. They both work.
    I'll graduate the comments to an answer as it's my preferred syntax.

    0 讨论(0)
  • 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[];
    
    0 讨论(0)
提交回复
热议问题