sqlcmd.net validated sql reference
beginner updating MySQL MariaDB SQL Server PostgreSQL SQLite

Update Rows

Modify existing rows with `UPDATE`, then verify the changed data with a stable query.

Docker-validated Not currently validation-green

Update one matching row

The WHERE clause is the safety boundary. Without it, the update would touch every row in the table.

Rows loaded before the example query runs.
Setup
CREATE TABLE users (id INT, status VARCHAR(20));

INSERT INTO
  users (id, status)
VALUES
  (1, 'pending'),
  (2, 'active');
Shared across supported engines.
SQL
UPDATE users
SET
  status = 'active'
WHERE
  id = 1;

SELECT
  id,
  status
FROM
  users
ORDER BY
  id;
Returned rows for the shared example.
idstatus
1active
2active

The verification output matches, but the execution blocks differ so the final captured table state stays deterministic.

Where this command helps.

  • changing status or ownership fields on existing rows
  • backfilling corrected values after a data cleanup

What the command is doing.

UPDATE changes data that already exists. In teaching content, it is usually clearer to show the table after the update instead of relying on engine-specific row count messages.