// SQLite error reference

SQLITE_CONSTRAINT_TRIGGER: RAISE() in a trigger aborted it

A trigger called RAISE(ABORT, ...), RAISE(FAIL, ...) or RAISE(ROLLBACK, ...) and stopped the statement. The message is the text the trigger passed to RAISE.

Result code
SQLITE_CONSTRAINT_TRIGGER
Name
1811
Category
Extended result codes
Error message
constraint failed

What it means

SQLITE_CONSTRAINT_TRIGGER (1811) means a RAISE() function inside a trigger fired. Triggers use it to enforce rules a CHECK can't express, such as rules that look at other tables. The error message is the text given to RAISE, so a well-written trigger tells you exactly what was wrong.

Common causes

  • The data broke a business rule enforced by a trigger.
  • A trigger left over from an older version of the schema, enforcing a rule that no longer applies.

How to fix it

  1. Read the message and find the trigger that raised it.

    SELECT name, sql FROM sqlite_schema WHERE type = 'trigger' AND tbl_name = 'orders';
  2. Fix the data, or drop and recreate the trigger if the rule is outdated.

    DROP TRIGGER IF EXISTS orders_no_negative_total;

Reproduce it safely

CREATE TABLE t (n INTEGER);
CREATE TRIGGER t_positive BEFORE INSERT ON t WHEN NEW.n < 0
BEGIN SELECT RAISE(ABORT, 'n must not be negative'); END;
INSERT INTO t VALUES (-1);  -- Runtime error: n must not be negative (19)

Related errors

More extended result codes errors

The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.

// fewer errors, faster fixes

Work on SQLite in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.