@@ -621,9 +621,9 @@ INSERT INTO employees_log SELECT *, current_timestamp FROM upd;
621
621
expression is used to reference values originally proposed for
622
622
insertion:
623
623
<programlisting>
624
- INSERT INTO distributors (did, dname)
625
- VALUES (5, 'Gizmo transglobal'), (6, 'Associated Computing, inc')
626
- ON CONFLICT (did) DO UPDATE SET dname = EXCLUDED.dname;
624
+ INSERT INTO distributors (did, dname)
625
+ VALUES (5, 'Gizmo transglobal'), (6, 'Associated Computing, inc')
626
+ ON CONFLICT (did) DO UPDATE SET dname = EXCLUDED.dname;
627
627
</programlisting>
628
628
</para>
629
629
<para>
@@ -633,8 +633,8 @@ INSERT INTO employees_log SELECT *, current_timestamp FROM upd;
633
633
Example assumes a unique index has been defined that constrains
634
634
values appearing in the <literal>did</literal> column:
635
635
<programlisting>
636
- INSERT INTO distributors (did, dname) VALUES (7, 'Redline GmbH')
637
- ON CONFLICT (did) DO NOTHING;
636
+ INSERT INTO distributors (did, dname) VALUES (7, 'Redline GmbH')
637
+ ON CONFLICT (did) DO NOTHING;
638
638
</programlisting>
639
639
</para>
640
640
<para>
@@ -644,16 +644,16 @@ INSERT INTO employees_log SELECT *, current_timestamp FROM upd;
644
644
used to limit the rows actually updated (any existing row not
645
645
updated will still be locked, though):
646
646
<programlisting>
647
- -- Don't update existing distributors based in a certain ZIP code
648
- INSERT INTO distributors AS d (did, dname) VALUES (8, 'Anvil Distribution')
649
- ON CONFLICT (did) DO UPDATE
650
- SET dname = EXCLUDED.dname || ' (formerly ' || d.dname || ')'
651
- WHERE d.zipcode != '21201';
652
-
653
- -- Name a constraint directly in the statement (uses associated
654
- -- index to arbitrate taking the DO NOTHING action)
655
- INSERT INTO distributors (did, dname) VALUES (9, 'Antwerp Design')
656
- ON CONFLICT ON CONSTRAINT distributors_pkey DO NOTHING;
647
+ -- Don't update existing distributors based in a certain ZIP code
648
+ INSERT INTO distributors AS d (did, dname) VALUES (8, 'Anvil Distribution')
649
+ ON CONFLICT (did) DO UPDATE
650
+ SET dname = EXCLUDED.dname || ' (formerly ' || d.dname || ')'
651
+ WHERE d.zipcode <> '21201';
652
+
653
+ -- Name a constraint directly in the statement (uses associated
654
+ -- index to arbitrate taking the DO NOTHING action)
655
+ INSERT INTO distributors (did, dname) VALUES (9, 'Antwerp Design')
656
+ ON CONFLICT ON CONSTRAINT distributors_pkey DO NOTHING;
657
657
</programlisting>
658
658
</para>
659
659
<para>
@@ -664,11 +664,11 @@ INSERT INTO employees_log SELECT *, current_timestamp FROM upd;
664
664
<literal>is_active</literal> boolean column evaluates to
665
665
<literal>true</literal>:
666
666
<programlisting>
667
- -- This statement could infer a partial unique index on "did"
668
- -- with a predicate of "WHERE is_active", but it could also
669
- -- just use a regular unique constraint on "did"
670
- INSERT INTO distributors (did, dname) VALUES (10, 'Conrad International')
671
- ON CONFLICT (did) WHERE is_active DO NOTHING;
667
+ -- This statement could infer a partial unique index on "did"
668
+ -- with a predicate of "WHERE is_active", but it could also
669
+ -- just use a regular unique constraint on "did"
670
+ INSERT INTO distributors (did, dname) VALUES (10, 'Conrad International')
671
+ ON CONFLICT (did) WHERE is_active DO NOTHING;
672
672
</programlisting>
673
673
</para>
674
674
</refsect1>
0 commit comments