{
    "mode": "man",
    "parameter": "CREATE_CONVERSION",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/CREATE_CONVERSION/7/json",
    "generated": "2026-06-14T07:26:02Z",
    "synopsis": "CREATE [ DEFAULT ] CONVERSION name\nFOR sourceencoding TO destencoding FROM functionname",
    "sections": {
        "NAME": {
            "content": "CREATECONVERSION - define a new encoding conversion\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "CREATE [ DEFAULT ] CONVERSION name\nFOR sourceencoding TO destencoding FROM functionname\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "CREATE CONVERSION defines a new conversion between two character set encodings.\n\nConversions that are marked DEFAULT can be used for automatic encoding conversion between\nclient and server. To support that usage, two conversions, from encoding A to B and from\nencoding B to A, must be defined.\n\nTo be able to create a conversion, you must have EXECUTE privilege on the function and CREATE\nprivilege on the destination schema.\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "DEFAULT\nThe DEFAULT clause indicates that this conversion is the default for this particular\nsource to destination encoding. There should be only one default encoding in a schema for\nthe encoding pair.\n\nname\nThe name of the conversion. The conversion name can be schema-qualified. If it is not,\nthe conversion is defined in the current schema. The conversion name must be unique\nwithin a schema.\n\nsourceencoding\nThe source encoding name.\n\ndestencoding\nThe destination encoding name.\n\nfunctionname\nThe function used to perform the conversion. The function name can be schema-qualified.\nIf it is not, the function will be looked up in the path.\n\nThe function must have the following signature:\n\nconvproc(\ninteger,  -- source encoding ID\ninteger,  -- destination encoding ID\ncstring,  -- source string (null terminated C string)\ninternal, -- destination (fill with a null terminated C string)\ninteger,  -- source string length\nboolean   -- if true, don't throw an error if conversion fails\n) RETURNS integer;\n\nThe return value is the number of source bytes that were successfully converted. If the\nlast argument is false, the function must throw an error on invalid input, and the return\nvalue is always equal to the source string length.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Neither the source nor the destination encoding can be SQLASCII, as the server's behavior\nfor cases involving the SQLASCII “encoding” is hard-wired.\n\nUse DROP CONVERSION to remove user-defined conversions.\n\nThe privileges required to create a conversion might be changed in a future release.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To create a conversion from encoding UTF8 to LATIN1 using myfunc:\n\nCREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "CREATE CONVERSION is a PostgreSQL extension. There is no CREATE CONVERSION statement in the\nSQL standard, but a CREATE TRANSLATION statement that is very similar in purpose and syntax.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ALTER CONVERSION (ALTERCONVERSION(7)), CREATE FUNCTION (CREATEFUNCTION(7)), DROP CONVERSION\n(DROPCONVERSION(7))\n\n\n\nPostgreSQL 14.23                                2026                            CREATE CONVERSION(7)",
            "subsections": []
        }
    },
    "summary": "CREATECONVERSION - define a new encoding conversion",
    "flags": [],
    "examples": [
        "To create a conversion from encoding UTF8 to LATIN1 using myfunc:",
        "CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;"
    ],
    "see_also": [
        {
            "name": "ALTERCONVERSION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ALTERCONVERSION/7/json"
        },
        {
            "name": "CREATEFUNCTION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEFUNCTION/7/json"
        },
        {
            "name": "DROPCONVERSION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPCONVERSION/7/json"
        },
        {
            "name": "CONVERSION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CONVERSION/7/json"
        }
    ]
}