1CREATE COLLATION(7)      PostgreSQL 13.4 Documentation     CREATE COLLATION(7)
2
3
4

NAME

6       CREATE_COLLATION - define a new collation
7

SYNOPSIS

9       CREATE COLLATION [ IF NOT EXISTS ] name (
10           [ LOCALE = locale, ]
11           [ LC_COLLATE = lc_collate, ]
12           [ LC_CTYPE = lc_ctype, ]
13           [ PROVIDER = provider, ]
14           [ DETERMINISTIC = boolean, ]
15           [ VERSION = version ]
16       )
17       CREATE COLLATION [ IF NOT EXISTS ] name FROM existing_collation
18

DESCRIPTION

20       CREATE COLLATION defines a new collation using the specified operating
21       system locale settings, or by copying an existing collation.
22
23       To be able to create a collation, you must have CREATE privilege on the
24       destination schema.
25

PARAMETERS

27       IF NOT EXISTS
28           Do not throw an error if a collation with the same name already
29           exists. A notice is issued in this case. Note that there is no
30           guarantee that the existing collation is anything like the one that
31           would have been created.
32
33       name
34           The name of the collation. The collation name can be
35           schema-qualified. If it is not, the collation is defined in the
36           current schema. The collation name must be unique within that
37           schema. (The system catalogs can contain collations with the same
38           name for other encodings, but these are ignored if the database
39           encoding does not match.)
40
41       locale
42           This is a shortcut for setting LC_COLLATE and LC_CTYPE at once. If
43           you specify this, you cannot specify either of those parameters.
44
45       lc_collate
46           Use the specified operating system locale for the LC_COLLATE locale
47           category.
48
49       lc_ctype
50           Use the specified operating system locale for the LC_CTYPE locale
51           category.
52
53       provider
54           Specifies the provider to use for locale services associated with
55           this collation. Possible values are: icu, libc.  libc is the
56           default. The available choices depend on the operating system and
57           build options.
58
59       DETERMINISTIC
60           Specifies whether the collation should use deterministic
61           comparisons. The default is true. A deterministic comparison
62           considers strings that are not byte-wise equal to be unequal even
63           if they are considered logically equal by the comparison.
64           PostgreSQL breaks ties using a byte-wise comparison. Comparison
65           that is not deterministic can make the collation be, say, case- or
66           accent-insensitive. For that, you need to choose an appropriate
67           LC_COLLATE setting and set the collation to not deterministic here.
68
69           Nondeterministic collations are only supported with the ICU
70           provider.
71
72       version
73           Specifies the version string to store with the collation. Normally,
74           this should be omitted, which will cause the version to be computed
75           from the actual version of the collation as provided by the
76           operating system. This option is intended to be used by pg_upgrade
77           for copying the version from an existing installation.
78
79           See also ALTER COLLATION (ALTER_COLLATION(7)) for how to handle
80           collation version mismatches.
81
82       existing_collation
83           The name of an existing collation to copy. The new collation will
84           have the same properties as the existing one, but it will be an
85           independent object.
86

NOTES

88       CREATE COLLATION takes a SHARE ROW EXCLUSIVE lock, which is
89       self-conflicting, on the pg_collation system catalog, so only one
90       CREATE COLLATION command can run at a time.
91
92       Use DROP COLLATION to remove user-defined collations.
93
94       See Section 23.2.2.3 for more information on how to create collations.
95
96       When using the libc collation provider, the locale must be applicable
97       to the current database encoding. See CREATE DATABASE
98       (CREATE_DATABASE(7)) for the precise rules.
99

EXAMPLES

101       To create a collation from the operating system locale fr_FR.utf8
102       (assuming the current database encoding is UTF8):
103
104           CREATE COLLATION french (locale = 'fr_FR.utf8');
105
106       To create a collation using the ICU provider using German phone book
107       sort order:
108
109           CREATE COLLATION german_phonebook (provider = icu, locale = 'de-u-co-phonebk');
110
111       To create a collation from an existing collation:
112
113           CREATE COLLATION german FROM "de_DE";
114
115       This can be convenient to be able to use operating-system-independent
116       collation names in applications.
117

COMPATIBILITY

119       There is a CREATE COLLATION statement in the SQL standard, but it is
120       limited to copying an existing collation. The syntax to create a new
121       collation is a PostgreSQL extension.
122

SEE ALSO

124       ALTER COLLATION (ALTER_COLLATION(7)), DROP COLLATION
125       (DROP_COLLATION(7))
126
127
128
129PostgreSQL 13.4                      2021                  CREATE COLLATION(7)
Impressum