typestar

INSERT rows in SQL

INSERT adds rows; one VALUES list per row.

INSERT INTO products (sku, name, price)
VALUES
    ('TS-001', 'Keyboard', 89.00),
    ('TS-002', 'Keycap set', 45.50),
    ('TS-003', 'Wrist rest', 19.99)
RETURNING id, sku;

How it works

  1. Naming the columns makes the statement survive a schema change.
  2. Several tuples in one statement insert in a single pass.
  3. RETURNING hands back the generated ids.

Keywords and builtins used here

The run, in numbers

Lines
6
Characters to type
161
Tokens
45
Three-star pace
80 tpm

At the three-star pace of 80 tokens a minute, this run takes about 34 seconds.

Type this snippet

Step 4 of 8 in Tables & rows, step 17 of 23 in Language basics.

← Previous Next →