Case conversion and text collation
Core idea
UPPER and LOWER transform letter case. A collation is a set of rules used to compare and sort text. These are separate concepts: changing a display string is not the same as defining how a database treats equality or ordering.
Minimal example
SELECT UPPER('Pen'), LOWER('NOTEBOOK'), LOWER('É');Expected SQLite rows (JSON notation; null means SQL NULL):
[ [ "PEN", "notebook", "É" ]]How it works
UPPER(text) and LOWER(text) can prepare a display value or assist a simple search. SQLite built-ins without extensions only fold ASCII letters. PostgreSQL case mapping depends on the applicable locale/collation. SQLite COLLATE NOCASE also folds only ASCII letters; it is not a portable Unicode comparison. Case and accent sensitivity depend on selected engine and collation. The second example explicitly uses SQLite NOCASE, returning integer truth values. An expression on a column may need a matching expression index or suitable collation index; do not assume normal indexes always support it.
Practical example
SELECT 'Pen' = 'pen' COLLATE BINARY, 'Pen' = 'pen' COLLATE NOCASE, 'É' = 'é' COLLATE NOCASE;Expected SQLite rows (JSON notation; null means SQL NULL):
[ [ 0, 1, 0 ]]Common mistake and practice
Never promise universal case-insensitive search just by applying LOWER. Persian letters do not have uppercase/lowercase pairs like Latin letters. Practice: compare Pen and pen with SQLite BINARY and NOCASE, then compare É and é. Explain why outcomes differ.