// sqlite · sql behavior

recursive_triggers

Allow triggers to fire other triggers recursively, including themselves.

預設
0 (off)
Range
0, 1
Restart needed
否
Default checked on
SQLite 3.5x

其作用

Also makes REPLACE conflict resolution fire DELETE triggers for the rows it removes.

預設值

0 (off). Off (a stock SQLite 3.5x build).

Check the current value

PRAGMA recursive_triggers;

SELECT * FROM pragma_recursive_triggers;   -- table-valued form, usable in queries

Change it

PRAGMA recursive_triggers = ON;   -- this connection only

No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.

When to change it

When a trigger design needs recursion, or when DELETE triggers must run for rows removed by INSERT OR REPLACE.

What can go wrong

Existing triggers can start firing in new places; recursion depth is capped by SQLITE_MAX_TRIGGER_DEPTH (1000).

Questions about recursive_triggers

What is the default value of recursive_triggers in SQLite?

0 (off). Off (a stock SQLite 3.5x build).

Does changing recursive_triggers require a restart?

No. No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.

When should I change recursive_triggers?

When a trigger design needs recursion, or when DELETE triggers must run for rows removed by INSERT OR REPLACE.

Back to all SQLite settings, or check the SQLite manual for every option.

// one client for every engine

Check recursive_triggers on your own server

SQLly runs the query above against SQLite and the other engines in this reference, from one desktop app on macOS, Windows and Linux.