In order to actually insert array values into a table column, you of course need a way to refer to several values as an array in a SQL statement. The formal syntax of an array constant is a grouping of values, separated by delimiters (commas, for built-in data types), constrained by curly braces ( {} ), which are in turn constrained by single quotes.

 '{value1 , value2 , [...] }' 

The values in this syntax can be any valid PostgreSQL data type. As the entire array is constrained by single quotes, the use of single quotes within an array value must be escaped, just as they must be within a string constant. The use of commas to delimit the values, however, poses an interesting problem pertaining to the use of character strings which contain commas themselves, as the commas will be interpreted as delimiters if not within single-quotes. However, as just mentioned, the singles quotes constrain the array , not the array's values .

PostgreSQL's method of handling this is to use double-quotes to quote string constants where single-quotes would ordinarily be used outside of an array context.

 '{"value1" , "value 2, which contains a comma" }'

It's vital to remember that arrays require the single quotes surrounding the curly braces in order to be interpretted correctly by PostgreSQL. You can think of array constants as being akin to a special type of string constant, which is interpretted as an array based on where it is used (e.g., when used to add records to a target column which is of an array data type). This is because, unless used in an array context, a constant of the this format will be interpretted by PostgreSQL as a normal string constant (as it is bound by single quotes) which just happens to include curly braces.