Dup Ver Goto 📝

Columns Containing Sets Of Values

PT2/db/postgres postgres set does not exist
To
15 lines, 93 words, 520 chars Page 'SetColumns' does not exist.

This is the ARRAY type, not a set. As SQL uses the SET keyword in UPDATE.

CREATE TABLE a ( id SERIAL PRIMARY KEY, name TEXT, s TEXT[] );
INSERT INTO a ( name, s ) VALUES ( 'Hello World', '{ "hello", "world" }' ), ( 'Mr Flibble', '{ "mr", "flibble" }' );
SELECT name, s FROM a WHERE 'hello' = ANY( s );

outputs

    name     |       s       
-------------+---------------
 Hello World | {hello,world}

This does not prevent duplicate elements in a column, e.g. { "hello", "hello" } is possible.