SQL LCASE function
Returns the string with every character lowercased. The MySQL-only alias: same engine, same rules, different spelling.
- 類別
- Strings
- Returns
string- In this category
- 29 of 172
語法
LCASE(string)
引擎支援
| 引擎 | Support | 備註 |
|---|---|---|
| SQL Server | Not built in | No built-in equivalent. |
| PostgreSQL | Not built in | No built-in equivalent. |
| MySQL | 是 | Supported under this name. |
| SQLite | Not built in | No built-in equivalent. |
| Oracle | Not built in | No built-in equivalent. |
範例
MySQL
SELECT LCASE('ShIP') AS quiet; -- ship
MySQL
UPDATE users SET email = LCASE(email) WHERE id = 3;
小知識
- LCASE is an exact synonym of LOWER in MySQL; there is no reason to prefer either except consistency with your codebase.
- Every other major engine spells it LOWER only, so LCASE in a shared migration or ORM query will not port.
- Casing uses the argument's collation tables; for matching, a *_ci collation already ignores case without the function.
- The index rule applies as with LOWER: LCASE(column) = constant cannot use a plain index on the column.
Questions about LCASE
Should I use LCASE or LOWER?
They are the same in MySQL. LOWER is the portable spelling every engine accepts, so new code defaults to it.
Does LCASE change how comparisons work?
No. It returns a lowercased copy for that expression. Comparisons follow the column's collation with or without the function.
Why does LCASE('É') stay accented?
LCASE maps É to é, not to e. Accent-insensitive matching needs a collation such as utf8mb4_0900_ai_ci, not a casing function.
Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.
Related on SQLly
Cheat sheets for the engines that have it: MySQL.
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.