{
    "mode": "man",
    "parameter": "CREATE_COLLATION",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/CREATE_COLLATION/7/json",
    "generated": "2026-10-09T06:18:22Z",
    "synopsis": "CREATE COLLATION [ IF NOT EXISTS ] name (\n[ LOCALE = locale, ]\n[ LCCOLLATE = lccollate, ]\n[ LCCTYPE = lcctype, ]\n[ PROVIDER = provider, ]\n[ DETERMINISTIC = boolean, ]\n[ RULES = rules, ]\n[ VERSION = version ]\n)\nCREATE COLLATION [ IF NOT EXISTS ] name FROM existingcollation",
    "sections": {
        "NAME": {
            "content": "CREATECOLLATION - define a new collation\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "CREATE COLLATION [ IF NOT EXISTS ] name (\n[ LOCALE = locale, ]\n[ LCCOLLATE = lccollate, ]\n[ LCCTYPE = lcctype, ]\n[ PROVIDER = provider, ]\n[ DETERMINISTIC = boolean, ]\n[ RULES = rules, ]\n[ VERSION = version ]\n)\nCREATE COLLATION [ IF NOT EXISTS ] name FROM existingcollation\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "CREATE COLLATION defines a new collation using the specified operating system locale\nsettings, or by copying an existing collation.\n\nTo be able to create a collation, you must have CREATE privilege on the destination schema.\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "IF NOT EXISTS\nDo not throw an error if a collation with the same name already exists. A notice is\nissued in this case. Note that there is no guarantee that the existing collation is\nanything like the one that would have been created.\n\nname\nThe name of the collation. The collation name can be schema-qualified. If it is not, the\ncollation is defined in the current schema. The collation name must be unique within that\nschema. (The system catalogs can contain collations with the same name for other\nencodings, but these are ignored if the database encoding does not match.)\n\nlocale\nThe locale name for this collation. See Section 24.2.2.3.1 and Section 24.2.2.3.2 for\ndetails.\n\nIf provider is libc, this is a shortcut for setting LCCOLLATE and LCCTYPE at once. If\nyou specify locale, you cannot specify either of those parameters.\n\nlccollate\nIf provider is libc, use the specified operating system locale for the LCCOLLATE locale\ncategory.\n\nlcctype\nIf provider is libc, use the specified operating system locale for the LCCTYPE locale\ncategory.\n\nprovider\nSpecifies the provider to use for locale services associated with this collation.\nPossible values are icu (if the server was built with ICU support) or libc.  libc is the\ndefault. See Section 24.1.4 for details.\n\nDETERMINISTIC\nSpecifies whether the collation should use deterministic comparisons. The default is\ntrue. A deterministic comparison considers strings that are not byte-wise equal to be\nunequal even if they are considered logically equal by the comparison. PostgreSQL breaks\nties using a byte-wise comparison. Comparison that is not deterministic can make the\ncollation be, say, case- or accent-insensitive. For that, you need to choose an\nappropriate LOCALE setting and set the collation to not deterministic here.\n\nNondeterministic collations are only supported with the ICU provider.\n\nrules\nSpecifies additional collation rules to customize the behavior of the collation. This is\nsupported for ICU only. See Section 24.2.3.4 for details.\n\nversion\nSpecifies the version string to store with the collation. Normally, this should be\nomitted, which will cause the version to be computed from the actual version of the\ncollation as provided by the operating system. This option is intended to be used by\npgupgrade for copying the version from an existing installation.\n\nSee also ALTER COLLATION (ALTERCOLLATION(7)) for how to handle collation version\nmismatches.\n\nexistingcollation\nThe name of an existing collation to copy. The new collation will have the same\nproperties as the existing one, but it will be an independent object.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "CREATE COLLATION takes a SHARE ROW EXCLUSIVE lock, which is self-conflicting, on the\npgcollation system catalog, so only one CREATE COLLATION command can run at a time.\n\nUse DROP COLLATION to remove user-defined collations.\n\nSee Section 24.2.2.3 for more information on how to create collations.\n\nWhen using the libc collation provider, the locale must be applicable to the current database\nencoding. See CREATE DATABASE (CREATEDATABASE(7)) for the precise rules.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To create a collation from the operating system locale frFR.utf8 (assuming the current\ndatabase encoding is UTF8):\n\nCREATE COLLATION french (locale = 'frFR.utf8');\n\nTo create a collation using the ICU provider using German phone book sort order:\n\nCREATE COLLATION germanphonebook (provider = icu, locale = 'de-u-co-phonebk');\n\nTo create a collation using the ICU provider, based on the root ICU locale, with custom\nrules:\n\nCREATE COLLATION custom (provider = icu, locale = 'und', rules = '&V << w <<< W');\n\nSee Section 24.2.3.4 for further details and examples on the rules syntax.\n\nTo create a collation from an existing collation:\n\nCREATE COLLATION german FROM \"deDE\";\n\nThis can be convenient to be able to use operating-system-independent collation names in\napplications.\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "There is a CREATE COLLATION statement in the SQL standard, but it is limited to copying an\nexisting collation. The syntax to create a new collation is a PostgreSQL extension.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ALTER COLLATION (ALTERCOLLATION(7)), DROP COLLATION (DROPCOLLATION(7))\n\nPostgreSQL 16.14                                2026                             CREATE COLLATION(7)",
            "subsections": []
        }
    },
    "summary": "CREATECOLLATION - define a new collation",
    "flags": [],
    "examples": [
        "To create a collation from the operating system locale frFR.utf8 (assuming the current",
        "database encoding is UTF8):",
        "CREATE COLLATION french (locale = 'frFR.utf8');",
        "To create a collation using the ICU provider using German phone book sort order:",
        "CREATE COLLATION germanphonebook (provider = icu, locale = 'de-u-co-phonebk');",
        "To create a collation using the ICU provider, based on the root ICU locale, with custom",
        "rules:",
        "CREATE COLLATION custom (provider = icu, locale = 'und', rules = '&V << w <<< W');",
        "See Section 24.2.3.4 for further details and examples on the rules syntax.",
        "To create a collation from an existing collation:",
        "CREATE COLLATION german FROM \"deDE\";",
        "This can be convenient to be able to use operating-system-independent collation names in",
        "applications."
    ],
    "see_also": [
        {
            "name": "ALTERCOLLATION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ALTERCOLLATION/7/json"
        },
        {
            "name": "DROPCOLLATION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPCOLLATION/7/json"
        },
        {
            "name": "COLLATION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/COLLATION/7/json"
        }
    ]
}