// strings reference

SQL NLS_INITCAP function

INITCAP with an explicit NLS_SORT: title-cases per a language's rules instead of the session default.

カテゴリ
Strings
Returns
string
In this category
26 of 172

構文

NLS_INITCAP(string [, 'NLS_SORT=sort_name'])

エンジンサポート

エンジンSupportメモ
SQL Server Not built in No built-in equivalent.
PostgreSQL Not built in No built-in equivalent.
MySQL Not built in No built-in equivalent.
SQLite Not built in No built-in equivalent.
Oracle はい Supported under this name.

例

Oracle

SELECT NLS_INITCAP('istanbul') AS plain FROM dual;  -- Istanbul

Oracle

SELECT NLS_INITCAP('istanbul', 'NLS_SORT=XTurkish') AS tr FROM dual;

知っておくと便利なこと

  • Without the second argument it uses the session's NLS_SORT, which may not match the data's language.
  • Linguistic sorts handle special pairs: NLS_INITCAP('istanbul', 'NLS_SORT=XTurkish') starts with a dotted capital I.
  • Sisters NLS_UPPER and NLS_LOWER take the same parameter; plain INITCAP ignores locale rules entirely.
  • Oracle only. Other engines reach for per-expression COLLATE clauses (PostgreSQL, SQL Server) instead.

Questions about NLS_INITCAP

How is NLS_INITCAP different from INITCAP?

INITCAP uses the session's default sort; NLS_INITCAP lets you name one per call, so mixed-language data can be cased correctly in one query.

What NLS_SORT values can I use?

BINARY plus the linguistic sorts Oracle ships: XTurkish, XGerman, XDanish and dozens more. The X- prefix enables the special uppercase expansions.

Does PostgreSQL need this?

PostgreSQL picks casing rules per expression with COLLATE, e.g. lower('I' COLLATE "tr-TR-x-icu"), so there is no separate function.

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

Cheat sheets for the engines that have it: Oracle.

// 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.