1388
MariaDBerrorqueryhigh confidence

UPDATE without WHERE that uses a KEY column blocked by safe update mode

Production Risk

Low — statement blocked; this is a safety feature, not a data risk.

What this means

Safe update mode (SQL_SAFE_UPDATES=1) is active and a DELETE or UPDATE was issued without a WHERE clause that references a key column.

Why it happens
  1. 1Running an UPDATE or DELETE without a WHERE clause in safe mode
  2. 2WHERE clause exists but doesn't use a key column
How to reproduce
trigger — this will error
trigger — this will error
SET SQL_SAFE_UPDATES = 1; UPDATE users SET status = 'active';

expected output

ERROR 1388 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

Fix 1

Add a WHERE clause using a key column

Add a WHERE clause using a key column
UPDATE users SET status = 'active' WHERE id > 0;

Why this works

Safe mode requires a key-based WHERE condition.

Fix 2

Disable safe mode for the session

Disable safe mode for the session
SET SQL_SAFE_UPDATES = 0;

Why this works

Removes the restriction; use with caution.

What not to do

Version notes

Sources
Official documentation ↗

MySQL 8.0 — 1388 ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors