CREATE_USER_MAPPING(7pg14)

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

πŸ’… CREATE USER MAPPING πŸ’…

okay bestie, this is the CREATE USER MAPPING(7) page from the PostgreSQL 14.24 documentation, and we’re gonna make it make sense fr fr 🫢✨

🌸 NAME 🌸

CREATE_USER_MAPPING β€” define a new mapping of a user to a foreign server. that’s the whole vibe πŸ’«

✨ SYNOPSIS ✨

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

πŸ’– DESCRIPTION πŸ’–

CREATE USER MAPPING defines a mapping of a user to a foreign 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. it’s giving β€œhere’s how this user connects over there” πŸ”₯

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 if USAGE privilege on the server has been granted to the user. periodt πŸ‘‘

πŸŽ€ 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. note that there is no guarantee that the existing user mapping is anything like the one that would have been created. so like… it exists, but don’t assume it’s your fave πŸ’€
  • user_name β€” the name of an existing user that is mapped to foreign server. CURRENT_ROLE, CURRENT_USER, and USER match the name of the current user. when PUBLIC is specified, a so-called public mapping is created that is used when no user-specific mapping is applicable. iconic fallback behavior ngl 🌈
  • server_name β€” the name of an existing server for which the user mapping is to be created.
  • 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. option names must be unique. the allowed option names and values are specific to the server’s foreign-data wrapper. so yeah, check with your FDW bestie before you go wild πŸ¦‹

πŸ“ EXAMPLES πŸ“

create a user mapping for user bob, server foo:

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

slay, bob is mapped πŸ’…βœ¨

🌟 COMPATIBILITY 🌟

CREATE USER MAPPING conforms to ISO/IEC 9075-9 (SQL/MED). standards girlie behavior, we love to see it πŸ‘‘

🧚 SEE ALSO 🧚


mwah πŸ’‹ this page is brought to you by PostgreSQL 14.24, dated 2026. go forth and map responsibly, bestie πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from