ALTER_USER_MAPPING(7pg18)
โจ ALTER USER MAPPING ๐
okay bestie, so this is the PostgreSQL 18.6 documentation for ALTER USER MAPPING, and it lives in section 7 of the manual. yes it's giving "change the definition of a user mapping" and honestly? it's iconic. let's get into it ๐ซถ
๐ธ NAME ๐ธ
ALTER_USER_MAPPING โ change the definition of a user mapping
โญ SYNOPSIS โญ
ALTER USER MAPPING FOR { user_name | USER | CURRENT_ROLE | CURRENT_USER | SESSION_USER | PUBLIC }
SERVER server_name
OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )
no cap, that's the whole shape of it ๐
๐ฆ DESCRIPTION ๐ฆ
ALTER USER MAPPING changes the definition of a user mapping. that's it, that's the vibe โจ
okay but here's the tea on who is allowed to do it, because permissions are literally the main character here:
- the owner of a foreign server can alter user mappings for that server for any user ๐
- also, a user can alter a user mapping for their own user name โ but only if
USAGEprivilege on the server has been granted to that user
so like, know your lane, but also know your rights ๐
๐ PARAMETERS ๐
user_nameโ the user name of the mapping.CURRENT_ROLE,CURRENT_USER, andUSERall match the name of the current user. andPUBLIC? that one matches all present and future user names in the system. everybody. all of them. ๐server_nameโ the server name of the user mapping.OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )โ change options for the user mapping. the new options override any previously specified options.ADD,SET, andDROPspecify the action to be performed.ADDis assumed if no operation is explicitly specified (so it's the default, she's the main character by default, periodt). option names must be unique, and options are also validated by the server's foreign-data wrapper. so like, the wrapper gets a say too ๐ง
๐ฅ EXAMPLES ๐ฅ
change the password for user mapping bob, server foo:
ALTER USER MAPPING FOR bob SERVER foo OPTIONS (SET password 'public');
slay. that's the example. go off bob ๐
๐ COMPATIBILITY ๐
ALTER USER MAPPING conforms to ISO/IEC 9075-9 (SQL/MED). but bestie, there's a subtle syntax issue ๐ the standard omits the FOR key word. meanwhile both CREATE USER MAPPING and DROP USER MAPPING use FOR in analogous positions, and IBM DB2 (being the other major SQL/MED implementation) also requires it for ALTER USER MAPPING. so PostgreSQL diverges from the standard here, in the interest of consistency and interoperability. not her being the reasonable one fr fr ๐
๐ SEE ALSO ๐
CREATE USER MAPPING(CREATE_USER_MAPPING(7))DROP USER MAPPING(DROP_USER_MAPPING(7))
and that's the whole page, bestie!! this was PostgreSQL 18.6, dated 2026, and it's the ALTER USER MAPPING(7) manual page โ go forth and alter those mappings responsibly, mwah ๐โจ๐๐ฆ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms