Skip to content
masterclass Buddy

PostgreSQL · Command

INSERT

INSERT adds one or more complete rows to a PostgreSQL table. It can use values, defaults, or a query, and ON CONFLICT can skip or update conflicting rows.

Last updated

Syntax

[ WITH [ RECURSIVE ] with_query [, ...] ] INSERT INTO table_name [ AS alias ] [ ( column_name [, ...] ) ] [ OVERRIDING { SYSTEM | USER } VALUE ] { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } [ ON CONFLICT [ conflict_target ] conflict_action ] [ RETURNING [ WITH ( { OLD | NEW } AS output_alias [, ...] ) ] { * | output_expression [ [ AS ] output_name ] } [, ...] ]

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • WITH
  • SELECT
  • COPY
  • MERGE
  • UPDATE

Source: PostgreSQL: Documentation: 18: INSERT. Checked 2026-11-03.