{
    "mode": "man",
    "parameter": "CREATE_USER_MAPPING",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/CREATE_USER_MAPPING/7/json",
    "generated": "2026-05-30T05:14:50Z",
    "synopsis": "CREATE USER MAPPING [ IF NOT EXISTS ] FOR { username | USER | CURRENTROLE | CURRENTUSER | PUBLIC }\nSERVER servername\n[ OPTIONS ( option 'value' [ , ... ] ) ]",
    "sections": {
        "NAME": {
            "content": "CREATEUSERMAPPING - define a new mapping of a user to a foreign server\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "CREATE USER MAPPING [ IF NOT EXISTS ] FOR { username | USER | CURRENTROLE | CURRENTUSER | PUBLIC }\nSERVER servername\n[ OPTIONS ( option 'value' [ , ... ] ) ]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "CREATE USER MAPPING defines a mapping of a user to a foreign server. A user mapping typically\nencapsulates connection information that a foreign-data wrapper uses together with the\ninformation encapsulated by a foreign server to access an external data resource.\n\nThe owner of a foreign server can create user mappings for that server for any user. Also, a\nuser can create a user mapping for their own user name if USAGE privilege on the server has\nbeen granted to the user.\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "IF NOT EXISTS\nDo not throw an error if a mapping of the given user to the given foreign server already\nexists. A notice is issued in this case. Note that there is no guarantee that the\nexisting user mapping is anything like the one that would have been created.\n\nusername\nThe name of an existing user that is mapped to foreign server.  CURRENTROLE,\nCURRENTUSER, and USER match the name of the current user. When PUBLIC is specified, a\nso-called public mapping is created that is used when no user-specific mapping is\napplicable.\n\nservername\nThe name of an existing server for which the user mapping is to be created.\n\nOPTIONS ( option 'value' [, ... ] )\nThis clause specifies the options of the user mapping. The options typically define the\nactual user name and password of the mapping. Option names must be unique. The allowed\noption names and values are specific to the server's foreign-data wrapper.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Create a user mapping for user bob, server foo:\n\nCREATE USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'secret');\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "CREATE USER MAPPING conforms to ISO/IEC 9075-9 (SQL/MED).\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ALTER USER MAPPING (ALTERUSERMAPPING(7)), DROP USER MAPPING (DROPUSERMAPPING(7)), CREATE\nFOREIGN DATA WRAPPER (CREATEFOREIGNDATAWRAPPER(7)), CREATE SERVER (CREATESERVER(7))\n\n\n\nPostgreSQL 14.23                                2026                          CREATE USER MAPPING(7)",
            "subsections": []
        }
    },
    "summary": "CREATEUSERMAPPING - define a new mapping of a user to a foreign server",
    "flags": [],
    "examples": [
        "Create a user mapping for user bob, server foo:",
        "CREATE USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'secret');"
    ],
    "see_also": [
        {
            "name": "ALTERUSERMAPPING",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ALTERUSERMAPPING/7/json"
        },
        {
            "name": "DROPUSERMAPPING",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPUSERMAPPING/7/json"
        },
        {
            "name": "CREATEFOREIGNDATAWRAPPER",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEFOREIGNDATAWRAPPER/7/json"
        },
        {
            "name": "CREATESERVER",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATESERVER/7/json"
        },
        {
            "name": "MAPPING",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/MAPPING/7/json"
        }
    ]
}