Complete the code to insert a new user with id 1 and name 'Alice'.
INSERT INTO users (id, name) VALUES (1, 'Alice') [1];
The ON CONFLICT DO NOTHING clause tells PostgreSQL to skip the insert if a conflict occurs on any unique constraint.
Complete the code to update the user's name to 'Bob' if the id conflicts.
INSERT INTO users (id, name) VALUES (1, 'Bob') ON CONFLICT (id) [1];
The DO UPDATE SET name = EXCLUDED.name clause updates the existing row's name to the new value on conflict.
Fix the error in the code to update the user's email on conflict.
INSERT INTO users (id, email) VALUES (2, 'bob@example.com') ON CONFLICT (id) DO UPDATE SET email = [1];
Use EXCLUDED.email to refer to the new value being inserted during the conflict update.
Fill both blanks to insert or update the user's name and email on conflict.
INSERT INTO users (id, name, email) VALUES (3, 'Carol', 'carol@example.com') ON CONFLICT (id) DO UPDATE SET name = [1], email = [2];
Use EXCLUDED.name and EXCLUDED.email to update the existing row with the new values on conflict.
Fill all three blanks to insert or update the user's name, email, and age on conflict.
INSERT INTO users (id, name, email, age) VALUES (4, 'Dave', 'dave@example.com', 30) ON CONFLICT (id) DO UPDATE SET name = [1], email = [2], age = [3];
Use EXCLUDED.name, EXCLUDED.email, and EXCLUDED.age to update all columns with the new values on conflict.