// strings reference

SQL LOWER function

Returns the string with every character lowercased. Its main job is normalizing emails, codes and identifiers before comparing or storing them.

Categoria
Strings
Returns
string
In this category
5 of 172

Sintaxe

LOWER(string)

Suporte a mecanismos

MotorSupportNotas
SQL Server Sim Supported under this name.
PostgreSQL Sim Supported under this name.
MySQL Sim Supported under this name.
SQLite Sim Supported under this name.
Oracle Sim Supported under this name.

Exemplos

Any engine

SELECT LOWER('MiXeD') AS quiet;  -- mixed

PostgreSQL

CREATE INDEX users_email_lower_idx ON users (LOWER(email));

Bom saber

  • Normalization usually happens once, on write: UPDATE users SET email = LOWER(email) beats LOWER() on every read afterwards.
  • PostgreSQL's citext extension gives a case-insensitive text type, so plain = comparisons ignore case without LOWER() calls or expression indexes.
  • Like UPPER, LOWER(column) = constant in a WHERE clause disables a plain index; index the expression instead.

Questions about LOWER

Is LOWER the same in every database?

For ASCII, yes. Beyond that it depends on the collation: SQLite's built-in LOWER only handles ASCII, and special cases like the Turkish dotted İ come out differently between engines and between collations on one engine.

Should I LOWER data on the way in or the way out?

On the way in, if the lowercase form is the data (emails, codes). Lowering on every read costs CPU and index usage forever.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.