CRUD on One Page: Four Verbs, Four SQL Statements

CRUD stands for Create, Read, Update and Delete, the four basic things an app does with data. This page lays them out like a poster: four blocks, each with a short caption, a tiny SQL example and the everyday app action it matches.

Block 1: Create

Picture: a plus sign adding a new card to a stack.

Caption: add a new row.

INSERT INTO tasks (title, done) VALUES ('Buy milk', false);

In an app: a "Save" button on a new form. On the web this is often an HTTP POST request.

Block 2: Read

Picture: a magnifying glass over the stack.

Caption: look at rows without changing them.

SELECT id, title, done FROM tasks WHERE done = false;

In an app: opening a list page or a detail page. On the web this is usually an HTTP GET request.

Block 3: Update

Picture: a pencil editing one card.

Caption: change values in existing rows.

UPDATE tasks SET done = true WHERE id = 3;

In an app: ticking a checkbox or editing a form. On the web this is often PUT or PATCH, or a POST from a simple form.

Block 4: Delete

Picture: one card going into a bin.

Caption: remove rows.

DELETE FROM tasks WHERE id = 3;

In an app: a "Remove" button, ideally with an "Are you sure?" step. On the web this is often HTTP DELETE.

The poster in one table

CRUDSQLTypical web actionChanges data?
CreateINSERTPOSTyes
ReadSELECTGETno
UpdateUPDATEPUT / PATCHyes
DeleteDELETEDELETEyes

The warning strip along the bottom

Picture: a yellow-and-black stripe.

Caption: UPDATE and DELETE without a WHERE clause change every row. Check WHERE before you press Enter, and practise on a copy.

A second strip: safety

Caption: when values come from a form, pass them with placeholders, for example INSERT INTO tasks (title) VALUES (?). This keeps user text from being treated as SQL.

Soft deletes, in one small box

Some apps never truly delete. They add a column such as deleted_at and set it instead, so data can be restored. The "Delete" button then runs an UPDATE. It is a common pattern worth knowing about, though not something you need on day one.

Where to go next

The Long Read on Create, Read, Update and Delete explains each statement in depth, and CRUD With a Tiny To-Do List walks through a complete small example.

A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.