UPSERT (ON CONFLICT)
Insert or update if exists (PostgreSQL)
MutationSQL
INSERT INTO users (email, name)
VALUES ('alice@example.com', 'Alice')
ON CONFLICT (email)
DO UPDATE SET name = EXCLUDED.name;What each clause does
ON CONFLICT (email) detects unique violations. DO UPDATE SET applies changes when a conflict occurs (PostgreSQL syntax).