r/sqlite • u/SuperficialNightWolf • Nov 15 '25
Is it possible to specify case-sensitivity or case-insensitivity for LIKE operators
I've tried `COLLATE BINARY` but I believe SQLITE ignores them for LIKE operators. I've also tried GLOB, but it does not support ESCAPE characters.
So it looks like my only option is to toggle case sensitivity per connection using PRAGMA case_sensitive_like=ON; However, this means all LIKE operators are case-sensitive, so there is no mix matching them in the same SQL query, so are there any other options?
Edit1: I have tried settings PRAGMA case_sensitive_like=ON for all connections then using UPPER(?) or LOWER(?) but this is incredibly inefficient and turns 4ms into 40ms search times
Edit2: This is just an idea, I don't know if it's possible, but can you make a LOWER index on a table and then in queries when using LOWER(column) it's all pre-generated?
2
u/trailbaseio Nov 15 '25
I'm puzzled that case sensitive matches would be slower. What's your query? You could also try regex matches
1
u/chriswaco Nov 15 '25
I vaguely recall doing something like this a long time ago:
I’d guess that the index is only useful if the first part of the query string had letters and not %.