2 .\" Title: CREATE COLLATION
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "CREATE COLLATION" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 CREATE_COLLATION \- define a new collation
35 CREATE COLLATION [ IF NOT EXISTS ] \fIname\fR (
36 [ LOCALE = \fIlocale\fR, ]
37 [ LC_COLLATE = \fIlc_collate\fR, ]
38 [ LC_CTYPE = \fIlc_ctype\fR, ]
39 [ PROVIDER = \fIprovider\fR, ]
40 [ DETERMINISTIC = \fIboolean\fR, ]
41 [ RULES = \fIrules\fR, ]
42 [ VERSION = \fIversion\fR ]
44 CREATE COLLATION [ IF NOT EXISTS ] \fIname\fR FROM \fIexisting_collation\fR
48 \fBCREATE COLLATION\fR
49 defines a new collation using the specified operating system locale settings, or by copying an existing collation\&.
51 To be able to create a collation, you must have
53 privilege on the destination schema\&.
58 Do not throw an error if a collation with the same name already exists\&. A notice is issued in this case\&. Note that there is no guarantee that the existing collation is anything like the one that would have been created\&.
63 The name of the collation\&. The collation name can be schema\-qualified\&. If it is not, the collation is defined in the current schema\&. The collation name must be unique within that schema\&. (The system catalogs can contain collations with the same name for other encodings, but these are ignored if the database encoding does not match\&.)
68 The locale name for this collation\&. See
77 libc, this is a shortcut for setting
81 at once\&. If you specify
82 \fIlocale\fR, you cannot specify either of those parameters\&.
89 must be specified and set to either
101 libc, use the specified operating system locale for the
111 libc, use the specified operating system locale for the
118 Specifies the provider to use for locale services associated with this collation\&. Possible values are
121 (if the server was built with ICU support) or
124 is the default\&. See
131 Specifies whether the collation should use deterministic comparisons\&. The default is true\&. A deterministic comparison considers strings that are not byte\-wise equal to be unequal even if they are considered logically equal by the comparison\&. PostgreSQL breaks ties using a byte\-wise comparison\&. Comparison that is not deterministic can make the collation be, say, case\- or accent\-insensitive\&. For that, you need to choose an appropriate
135 set the collation to not deterministic here\&.
137 Nondeterministic collations are only supported with the ICU provider\&.
142 Specifies additional collation rules to customize the behavior of the collation\&. This is supported for ICU only\&. See
149 Specifies the version string to store with the collation\&. Normally, this should be omitted, which will cause the version to be computed from the actual version of the collation as provided by the operating system\&. This option is intended to be used by
151 for copying the version from an existing installation\&.
154 ALTER COLLATION (\fBALTER_COLLATION\fR(7))
155 for how to handle collation version mismatches\&.
158 \fIexisting_collation\fR
160 The name of an existing collation to copy\&. The new collation will have the same properties as the existing one, but it will be an independent object\&.
164 \fBCREATE COLLATION\fR
167 lock, which is self\-conflicting, on the
169 system catalog, so only one
170 \fBCREATE COLLATION\fR
171 command can run at a time\&.
175 to remove user\-defined collations\&.
179 for more information on how to create collations\&.
183 collation provider, the locale must be applicable to the current database encoding\&. See
184 CREATE DATABASE (\fBCREATE_DATABASE\fR(7))
185 for the precise rules\&.
188 To create a collation from the operating system locale
190 (assuming the current database encoding is
197 CREATE COLLATION french (locale = \*(Aqfr_FR\&.utf8\*(Aq);
203 To create a collation using the ICU provider using German phone book sort order:
209 CREATE COLLATION german_phonebook (provider = icu, locale = \*(Aqde\-u\-co\-phonebk\*(Aq);
215 To create a collation using the ICU provider, based on the root ICU locale, with custom rules:
221 CREATE COLLATION custom (provider = icu, locale = \*(Aqund\*(Aq, rules = \*(Aq&V << w <<< W\*(Aq);
229 for further details and examples on the rules syntax\&.
231 To create a collation from an existing collation:
237 CREATE COLLATION german FROM "de_DE";
243 This can be convenient to be able to use operating\-system\-independent collation names in applications\&.
247 \fBCREATE COLLATION\fR
248 statement in the SQL standard, but it is limited to copying an existing collation\&. The syntax to create a new collation is a
252 ALTER COLLATION (\fBALTER_COLLATION\fR(7)), DROP COLLATION (\fBDROP_COLLATION\fR(7))