RefLib

Reference library for AI

Back

postgresql_16:4.9.1.3 Selecting Locales

PostgreSQL 16 > Server Administration > Localization > Locale Support > Selecting Locales

Locales can be selected in different scopes depending on requirements. The above overview showed how locales are specified using initdb to set the defaults for the entire cluster. The following list shows where locales can be selected. Each item provides the defaults for the subsequent items, and each lower item allows overriding the defaults on a finer granularity.

1. As explained above, the environment of the operating system provides the defaults for the locales of a newly initialized database cluster. In many cases, this is enough: If the operating system is configured for the desired language/territory, then PostgreSQL will by default also behave according to that locale. 2. As shown above, command-line options for initdb specify the locale settings for a newly initialized database cluster. Use this if the operating system does not have the locale configuration you want for your database system. 3. A locale can be selected separately for each database. The SQL command CREATE DATABASE and its command-line equivalent createdb have options for that. Use this for example if a database cluster houses databases for multiple tenants with different requirements. 4. Locale settings can be made for individual table columns. This uses an SQL object called *collation* and is explained in (see postgresql_16:4.9.2). Use this for example to sort data in different languages or customize the sort order of a particular table. 5. Finally, locales can be selected for an individual query. Again, this uses SQL collation objects. This could be used to change the sort order based on run-time choices or for ad-hoc experimentation.

Back