On this page
  1. UPDATE
  2. Syntax & Overview
  3. Notes & Best Practices
  4. Example

UPDATE

Prev: `INSERT` | Up: clauses | Next: `DELETE`
Rel: clauses, SQL Query Execution Lifecycle
Ref: PostgreSQL — SQL Commands
Tags: #public #databases #sql #clauses #tier/core


Syntax & Overview

UPDATE users SET role = 'admin' WHERE id = 1;

Modifies existing rows matching WHERE.

Notes & Best Practices

Example

UPDATE inventory
SET quantity = quantity - 1
WHERE sku = 'BOOK-1' AND quantity > 0
RETURNING sku, quantity;

Linked from

Related notes