Data persistence uses PostgreSQL. Raw SQL builds fluency for interviews and debugging; Knex adds migrations, seeds, and a query builder your Express services call. Learn both: SQL shows what the database actually runs; Knex shows how the app stays maintainable.

How to update and delete with SQL — Basic

Modify or remove rows using UPDATE and DELETE with appropriate WHERE clauses.
Learn: Always include WHERE on UPDATE and DELETE unless you intend to touch every row. Check `rowCount` or RETURNING to confirm something actually changed—return 404 when no row matched.

Supplementary examples

Update and delete by id

UPDATE pastes SET name = 'Renamed' WHERE paste_id = 3;
DELETE FROM pastes WHERE paste_id = 3;

Course example

UPDATE employees
SET job_title = 'Chemical Engineer II', city = 'Lawrenceville'
WHERE job_title = 'Chemical Engineer' AND city = 'Trenton';

Additional references & examples

  • UPDATE

    Modify existing rows with WHERE clauses.

  • DELETE

    Remove rows safely with filters.

← All Raw SQL · SQL / Knex