CREATE_USER_MAPPING(7pg13)

πŸ“¦ version 13.23, in opensuse-leap 16.0

πŸ’… CREATE USER MAPPING

okay so this is the CREATE USER MAPPING page from the PostgreSQL 13.23 Documentation, and bestie, it's literally about giving a user a lil passport to a foreign server. Buckle up πŸ¦‹


✨ NAME ✨

CREATE_USER_MAPPING β€” define a new mapping of a user to a foreign server πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

CREATE USER MAPPING [ IF NOT EXISTS ] FOR { user_name | USER | CURRENT_USER | PUBLIC }
    SERVER server_name
    [ OPTIONS ( option 'value' [ , ... ] ) ]

look at her. gorgeous. no notes. πŸ’–


🌸 DESCRIPTION 🌸

So CREATE USER MAPPING defines a mapping of a user to a foreign server. Basically it's the glow-up that says "hey, this human belongs to this server."

A user mapping typically encapsulates connection information that a foreign-data wrapper uses together with the information encapsulated by a foreign server to access an external data resource. (Yes, that's a lot of words β€” the vibe is: your mapping holds the connection bits, the foreign server holds the server bits, and together they get you to the external data. team work makes the dream work 🫢)

Now the permission tea β˜•: the owner of a foreign server can create user mappings for that server for any user. Also, a user can create a user mapping for their own user name β€” but only if USAGE privilege on the server has been granted to that user. know your rights, girlie πŸ’…


πŸ¦‹ PARAMETERS πŸ¦‹

  • IF NOT EXISTS β€” do not throw an error if a mapping of the given user to the given foreign server already exists. a notice is issued in this case instead, so it's giving "we're not mad, we're just disappointed" 😌. Note that there is no guarantee that the existing user mapping is anything like the one that would have been created β€” so like, don't assume she's the same girl.
  • user_name β€” the name of an existing user that is mapped to foreign server. CURRENT_USER and USER both match the name of the current user (iconic shortcuts honestly). When PUBLIC is specified, a so-called public mapping is created that is used when no user-specific mapping is applicable β€” she's the default, the fallback, the main character of last resort πŸ‘‘
  • server_name β€” the name of an existing server for which the user mapping is to be created. gotta exist already, no inventing servers out here πŸ™ˆ
  • OPTIONS ( option 'value' [, ... ] ) β€” this clause specifies the options of the user mapping. The options typically define the actual user name and password of the mapping (yes, the juicy stuff πŸ”₯). Option names must be unique β€” no duplicates, that's so not slay. The allowed option names and values are specific to the server's foreign-data wrapper, so check with your wrapper before you commit, iykyk.

⭐ EXAMPLES ⭐

Create a user mapping for user bob, server foo:

CREATE USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'secret');

look at bob. connected. thriving. we love to see it 🌈


πŸ‘‘ COMPATIBILITY πŸ‘‘

CREATE USER MAPPING conforms to ISO/IEC 9075-9 (SQL/MED). standards-compliant queen, periodt. πŸ’œ


🧚 SEE ALSO 🧚


and that's the whole page, bestie πŸ’– this lil manual page is brought to you by PostgreSQL 13.23, dated 2025 β€” go forth and map your users, you absolute legend πŸŽ€βœ¨

πŸ“¦ where this page comes from