April 2017
Beginner to intermediate
360 pages
9h 35m
English
What happens if we try to add a value to a set that it already contains? Let's try adding carol to the list again:
UPDATE "user_status_updates" SET "starred_by_users" = "starred_by_users" + {'carol'} WHERE "username" = 'alice' AND "id" = 76e7a4d0-e796-11e3-90ce-5f98e903bf02;
Now, let's read the row from the database to see our update's effects:

As the definition of the SET data structure suggests, we see only one instance of carol in the set; the column itself guarantees the uniqueness of its values.
Read now
Unlock full access