Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/ref/create_collation.sgml`
fc6e60f6e8cc650624d90f25195106136801a00231a10f360000000100000fa2
<!--
doc/src/sgml/ref/create_collation.sgml
PostgreSQL documentation
-->

<refentry id="sql-createcollation">
 <indexterm zone="sql-createcollation">
  <primary>CREATE COLLATION</primary>
 </indexterm>

 <refmeta>
  <refentrytitle>CREATE COLLATION</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>CREATE COLLATION</refname>
  <refpurpose>define a new collation</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
<synopsis>
CREATE COLLATION [ IF NOT EXISTS ] <replaceable>name</replaceable> (
    [ LOCALE = <replaceable>locale</replaceable>, ]
    [ LC_COLLATE = <replaceable>lc_collate</replaceable>, ]
    [ LC_CTYPE = <replaceable>lc_ctype</replaceable>, ]
    [ PROVIDER = <replaceable>provider</replaceable>, ]
    [ DETERMINISTIC = <replaceable>boolean</replaceable>, ]
    [ RULES = <replaceable>rules</replaceable>, ]
    [ VERSION = <replaceable>version</replaceable> ]
)
CREATE COLLATION [ IF NOT EXISTS ] <replaceable>name</replaceable> FROM <replaceable>existing_collation</replaceable>
</synopsis>
 </refsynopsisdiv>

 <refsect1 id="sql-createcollation-description">
  <title>Description</title>

  <para>
   <command>CREATE COLLATION</command> defines a new collation using
   the specified operating system locale settings,
   or by copying an existing collation.
 </para>

  <para>
   To be able to create a collation, you must
   have <literal>CREATE</literal> privilege on the destination schema.
  </para>
 </refsect1>


 <refsect1>
  <title>Parameters</title>

   <variablelist>
    <varlistentry>
     <term><literal>IF NOT EXISTS</literal></term>
     <listitem>
      <para>
       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.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><replaceable>name</replaceable></term>

     <listitem>
      <para>
       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.)
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><replaceable>locale</replaceable></term>

     <listitem>
      <para>
       The locale name for this collation. See <xref
       linkend="collation-managing-create-libc"/> and <xref
       linkend="collation-managing-create-icu"/> for details.
      </para>
      <para>
       If <replaceable>provider</replaceable> is <literal>libc</literal>, this
       is a shortcut for setting <symbol>LC_COLLATE</symbol> and
       <symbol>LC_CTYPE</symbol> at once.  If you specify
       <replaceable>locale</replaceable>, you cannot specify either of those
       parameters.
      </para>
      <para>
       If <replaceable>provider</replaceable> is <literal>builtin</literal>,
       then <replaceable>locale</replaceable> must be specified and set to
       either <literal>C</literal>, <literal>C.UTF-8</literal> or
       <literal>PG_UNICODE_FAST</literal>.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><replaceable>lc_collate</replaceable></term>

     <listitem>
      <para>
       If <replaceable>provider</replaceable> is <literal>libc</literal>, use
       the specified operating system locale for the
       <symbol>LC_COLLATE</symbol> locale category.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><replaceable>lc_ctype</replaceable></term>

     <listitem>
      <para>
       If <replaceable>provider</replaceable> is <literal>libc</literal>, use
       the specified operating system

Title: CREATE COLLATION
Summary
The CREATE COLLATION command defines a new collation, either by using operating system locale settings or by copying an existing collation. The user must have CREATE privilege on the destination schema. The command allows specifying the collation name, locale, LC_COLLATE, LC_CTYPE, PROVIDER, DETERMINISTIC, RULES, and VERSION. It also supports creating a collation if one with the same name doesn't already exist.