clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601446 fiddles created (47987 in the last week).

CREATE TABLE t1(id INT PRIMARY KEY, c TEXT);
 hidden batch(es)


INSERT INTO t1(id, c) VALUES (1,'a'), (2, 'b');
 hidden batch(es)


SELECT * FROM t1;
id c
1 a
2 b
 hidden batch(es)


INSERT INTO t1(id, c) VALUES (1, 'c'); -- UNIQUE constraint failed: t1.id
UNIQUE constraint failed: t1.id
 hidden batch(es)


INSERT INTO t1(id, c) VALUES (1, 'c') ON CONFLICT DO NOTHING;
 hidden batch(es)


SELECT * FROM t1;
id c
1 a
2 b
 hidden batch(es)


INSERT INTO t1(id, c) VALUES (1, 'c') ON CONFLICT(id) DO UPDATE SET c = excluded.c;
 hidden batch(es)


SELECT * FROM t1;
id c
1 c
2 b
 hidden batch(es)