SQLite обрабатывает varchar(5)
как text
(т.е. неограниченную строку), но вы можете добавить ограничение CHECK к столбцу:
create table pancakes (
name text check(name is null or length(name) <= 5)
)
Это даст вам ошибку «Сбой ограничения», если ваш name
слишком длинный:
sqlite> create table pancakes (name text not null check(length(name) <= 5));
sqlite> insert into pancakes (name) values ('1234');
sqlite> insert into pancakes (name) values ('12345');
sqlite> insert into pancakes (name) values ('123456');
Error: constraint failed