1 <!-- doc/src/sgml/ref/create_collation.sgml -->
3 <refentry id="SQL-CREATECOLLATION">
5 <refentrytitle>CREATE COLLATION</refentrytitle>
6 <manvolnum>7</manvolnum>
7 <refmiscinfo>SQL - Language Statements</refmiscinfo>
11 <refname>CREATE COLLATION</refname>
12 <refpurpose>define a new collation</refpurpose>
15 <indexterm zone="sql-createcollation">
16 <primary>CREATE COLLATION</primary>
21 CREATE COLLATION <replaceable>name</replaceable> (
22 [ LOCALE = <replaceable>locale</replaceable>, ]
23 [ LC_COLLATE = <replaceable>lc_collate</replaceable>, ]
24 [ LC_CTYPE = <replaceable>lc_ctype</replaceable> ]
26 CREATE COLLATION <replaceable>name</replaceable> FROM <replaceable>existing_collation</replaceable>
30 <refsect1 id="sql-createcollation-description">
31 <title>Description</title>
34 <command>CREATE COLLATION</command> defines a new collation using
35 the specified operating system locale settings,
36 or by copying an existing collation.
40 To be able to create a collation, you must
41 have <literal>CREATE</literal> privilege on the destination schema.
47 <title>Parameters</title>
51 <term><replaceable>name</replaceable></term>
55 The name of the collation. The collation name can be
56 schema-qualified. If it is not, the collation is defined in the
57 current schema. The collation name must be unique within that
58 schema. (The system catalogs can contain collations with the
59 same name for other encodings, but these are ignored if the
60 database encoding does not match.)
66 <term><replaceable>locale</replaceable></term>
70 This is a shortcut for setting <symbol>LC_COLLATE</symbol>
71 and <symbol>LC_CTYPE</symbol> at once. If you specify this,
72 you cannot specify either of those parameters.
78 <term><replaceable>lc_collate</replaceable></term>
82 Use the specified operating system locale for
83 the <symbol>LC_COLLATE</symbol> locale category. The locale
84 must be applicable to the current database encoding.
85 (See <xref linkend="sql-createdatabase"> for the precise
92 <term><replaceable>lc_ctype</replaceable></term>
96 Use the specified operating system locale for
97 the <symbol>LC_CTYPE</symbol> locale category. The locale
98 must be applicable to the current database encoding.
99 (See <xref linkend="sql-createdatabase"> for the precise
106 <term><replaceable>existing_collation</replaceable></term>
110 The name of an existing collation to copy. The new collation
111 will have the same properties as the existing one, but it
112 will be an independent object.
120 <refsect1 id="sql-createcollation-notes">
124 Use <command>DROP COLLATION</command> to remove user-defined collations.
128 See <xref linkend="collation"> for more information about collation
129 support in PostgreSQL.
133 <refsect1 id="sql-createcollation-examples">
134 <title>Examples</title>
137 To create a collation from the operating system locale
138 <literal>fr_FR.utf8</literal>
139 (assuming the current database encoding is <literal>UTF8</literal>):
141 CREATE COLLATION french (LOCALE = 'fr_FR.utf8');
146 To create a collation from an existing collation:
148 CREATE COLLATION german FROM "de_DE";
150 This can be convenient to be able to use operating-system-independent
151 collation names in applications.
156 <refsect1 id="sql-createcollation-compat">
157 <title>Compatibility</title>
160 There is a <command>CREATE COLLATION</command> statement in the SQL
161 standard, but it is limited to copying an existing collation. The
162 syntax to create a new collation is
163 a <productname>PostgreSQL</productname> extension.
168 <refsect1 id="sql-createcollation-seealso">
169 <title>See Also</title>
171 <simplelist type="inline">
172 <member><xref linkend="sql-altercollation"></member>
173 <member><xref linkend="sql-dropcollation"></member>