➕INSERT INTO
Add rows; name your columns
INSERT extends a table with new tuples. Listing target columns explicitly keeps application SQL stable when nullable columns gain defaults, when column order changes in migrations, or when new columns appear mid-sprint. Multi-row VALUES batches reduce round-trips; very large loads often move to INSERT … SELECT or engine-specific bulk tools.
INSERT INTO t VALUES (…)
Positional inserts break silently when someone adds a column in the middle of the table or reorders DDL in a dump, staging looks fine, production misaligns types or semantics.
INSERT INTO t (col_a, col_b) VALUES (…)
Always project the insert shape in the header. Pair with code review rules that reject bare VALUES lists without a column list.
Explicit column list
INSERT INTO instruments (instrument_id, model, installed_on)
VALUES ('SEQ-14', 'NovaSeq 6000', DATE '2026-02-10');| status |
|---|
| 1 row inserted |
Multi-row insert
INSERT INTO qc_thresholds (assay_code, metric, min_value, max_value)
VALUES
('ELISA-IGG', 'OD450', 0.05, 3.0),
('ELISA-IGG', 'CV_PERCENT', 0.0, 15.0),
('PCR-Q', 'CT', 10, 38);| rows_inserted |
|---|
| 3 |
RETURNING generated keys (PostgreSQL-style)
INSERT INTO sample_events (sample_id, event_type)
VALUES ('S-901', 'RECEIVED')
RETURNING event_id, recorded_at;| event_id | recorded_at |
|---|---|
| 44021 | 2026-04-12 09:14:02+00 |
🧭Pick the insert shape
Same logical row, different operational trade-offs.
| Pattern | When to use |
|---|---|
| INSERT … VALUES | Small static or app-generated batches; OLTP hot paths |
| INSERT … SELECT | ETL, staging promotion, repartitioning, same transaction as validation |
| RETURNING / OUTPUT | Fetch surrogate keys and defaults in one round-trip for APIs |
Triggers and FK checks
Bulk paths sometimes use session flags or minimal logging, verify that triggers, row-level security, and foreign keys still behave the way compliance expects before turning them on in production loads.
TL;DR
INSERT adds new rows to a table; column lists and VALUES tuples must satisfy NOT NULL, FK, CHECK, and UNIQUE constraints or the statement fails (unless deferred). Multi-row inserts amortize round trips; returning clauses fetch generated keys. Bulk loaders bypass some checks unless configured, validate the path you actually use in production.