1250
MySQLERRORNotableViewsHIGH confidence

Target table for UPDATE is not updatable

Production Risk

Low — update is rejected; refactor to use base tables.

What this means

ER_NON_UPDATABLE_TABLE (1250, SQLSTATE HY000) is raised when an UPDATE or DELETE targets a view that is not updatable. Views with joins, GROUP BY, DISTINCT, subqueries, or UNION are not updatable.

Why it happens
  1. 1Updating a view that contains a JOIN across multiple tables
  2. 2Updating a view defined with GROUP BY, HAVING, DISTINCT, or aggregate functions
  3. 3Updating a view that uses UNION or subqueries
How to reproduce
trigger — this will error
trigger — this will error
CREATE VIEW order_summary AS
  SELECT o.id, c.name, SUM(o.amount) AS total
  FROM orders o JOIN customers c ON o.customer_id = c.id
  GROUP BY o.id, c.name;

UPDATE order_summary SET total = 500 WHERE id = 1;  -- ERROR 1250

expected output

ERROR 1250 (HY000): The target table order_summary of the UPDATE is not updatable

Fix

Update the underlying base tables directly

Update the underlying base tables directly
UPDATE orders SET amount = 500 WHERE id = 1;

Why this works

Complex views with aggregates, JOINs, or DISTINCT are read-only; target the base table.

Sources
Official documentation ↗

MySQL 8.0 — 1250 ER_NON_UPDATABLE_TABLE

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

← All MySQL errors