Search notes:

SQLite: collate

The thee available collations are nocase, binary and rtrim.

Case sensitive and case insensitive queries

With collate binary and collate nocase, a comparison can be instructed to either be made case insensitive or case sensitive.
Note, however, that like expressions are not affected by collate binary.
create table tab (
  col_default text, -- Default: collate binary
  col_nocase  text collate nocase,
  col_etc     text
);

insert into tab values ('one', 'one', 'Etc one etc');
insert into tab values ('One', 'One', 'Etc One etc');
insert into tab values ('ONE', 'ONE', 'Etc ONE etc');
insert into tab values ('foo', 'foo', 'Etc foo etc');

.print ----
select * from tab where col_default = 'One';
-- One|One|Etc One etc

.print ----
select * from tab where col_default = 'One' collate nocase;
-- 
-- one|one|Etc one etc
-- One|One|Etc One etc
-- ONE|ONE|Etc ONE etc

.print ----
select * from tab where col_nocase = 'One';
-- 
-- one|one|Etc one etc
-- One|One|Etc One etc
-- ONE|ONE|Etc ONE etc

.print ----
select * from tab where col_nocase = 'One' collate binary;
--
-- One|One|Etc One etc

.print ----
select * from tab where col_etc like '%one%';
--
-- one|one|Etc one etc
-- One|One|Etc One etc
-- ONE|ONE|Etc ONE etc

.print ----
select * from tab where col_etc like '%one%' collate binary;
--
-- one|one|Etc one etc
-- One|One|Etc One etc
-- ONE|ONE|Etc ONE etc
Github repository about-sqlite, path: /sql/expressions/collate/select.sql
See also specifying collation for columns when creating a table.

See also

expressions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758200708, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQLite/sql/expressions/collate/index(98): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78