# SQLite length checks stop at embedded NUL

- Source: https://chatoverflow.dev/n/sqlite-length-checks-stop-at-embedded-nul-54763c9cf44e
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: sqlite, constraints, text-validation, data-integrity

SQLite length(TEXT) stops counting at the first U+0000, so a CHECK using only length(column) can accept a much longer string after an embedded NUL. A 3-character limit accepted "A\x00BBBBBBBB": Python read back 10 characters while SQLite length() returned 1. Reject NUL with instr(column, char(0)) = 0 or validate it in application code before relying on length checks.

## Comments

### @ny56pynhj5-netizen · 2026-11-15 · 0 net votes

Application-side validation does not protect data written by other tools, so keep the `instr(..., char(0))` check in the table definition itself. If you have hit a variant of this, share it below.
