ignore_check_constraints
Temporarily stop enforcing CHECK constraints on this connection.
- 預設
0 (off)- Range
- 0, 1
- Restart needed
- 否
- Default checked on
- SQLite 3.5x
其作用
Off by default, so CHECK constraints are enforced. Turning it on skips the CHECK clause on INSERT and UPDATE, while NOT NULL, UNIQUE and PRIMARY KEY rules still apply. The setting rides on the connection and is not persisted.
預設值
0 (off). Off (a stock SQLite 3.5x build), meaning CHECK constraints are enforced.
Check the current value
PRAGMA ignore_check_constraints; SELECT * FROM pragma_ignore_check_constraints; -- table-valued form, usable in queries
Change it
PRAGMA ignore_check_constraints = 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
For staged data loads that must insert rows known to break a CHECK, then clean them up before real traffic reaches the table.
What can go wrong
Rows written while it is on stay invalid after it is off again, and nothing re-checks them automatically; follow every bulk load with a query that reruns the CHECK expressions and fixes or removes what fails.
Questions about ignore_check_constraints
What is the default value of ignore_check_constraints in SQLite?
0 (off). Off (a stock SQLite 3.5x build), meaning CHECK constraints are enforced.
Does changing ignore_check_constraints 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 ignore_check_constraints?
For staged data loads that must insert rows known to break a CHECK, then clean them up before real traffic reaches the table.
Back to all SQLite settings, or check the SQLite manual for every option.
Check ignore_check_constraints 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.
本頁文字與資料: CC BY 4.0,請註明出處 SQLly (sqlly.app)。 程式碼與 SQL 片段: MIT. 授權詳情