Skip to main content
Module 8 · Lesson 1 of 429/57 in the course~14 min
Module lessons (1/4)

Inserting Data: INSERT

Lesson preview5 hands-on exercises readySQL Course · Module 8 — Writing and Modifying Data

Single and multi-row INSERTs, explicit column lists, and RETURNING clauses.

What you'll learn in this lesson

  • Add single and multiple rows in a single query with INSERT INTO tabella (colonne) VALUES (...), (...);.
  • Instantly retrieve generated keys or saved fields via RETURNING (PostgreSQL specific).
  • Understand how columns NOT NULL, DEFAULT, and SERIAL react when they are omitted in the insertion.

Overview

So far you have queried existing data; from this lesson we begin to modify the state of the database. INSERT is the command to write new rows safely respecting the schema, constraints and column types.

When you combine writing and parsing (or insert rows starting at SELECT via writable CTEs WITH inserted AS (INSERT ... RETURNING *)), the flow follows the modular pattern shown below:

Sections covered in this lesson

  1. 11. Mental Model: Explicit Columns, DEFAULT and RETURNING
  2. 22. Progressive & Annotated Examples
  3. 33. Interactive Laboratory: Data Pipeline and RETURNING
  4. 44. Diagnostic Verification (Quiz)
  5. 55. Progressive Practical Laboratory
Pro Lesson · Module 8 — Writing and Modifying Data

Unlock "Inserting Data: INSERT" and the full SQL Course curriculum

Single and multi-row INSERTs, explicit column lists, and RETURNING clauses.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in SQL Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.