ALTER_USER(7pg17)

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

πŸ’… ALTER_USER πŸ’…

ok so this is a 7 page from the PostgreSQL 17.11 docs, and yes bestie, the name is literally ALTER_USER β€” it's the one that changes a database role ✨


🌸 SYNOPSIS 🌸

here's the whole menu, verbatim, no cap β€” copy it exactly:

ALTER USER role_specification [ WITH ] option [ ... ]

where option can be:

      SUPERUSER | NOSUPERUSER
    | CREATEDB | NOCREATEDB
    | CREATEROLE | NOCREATEROLE
    | INHERIT | NOINHERIT
    | LOGIN | NOLOGIN
    | REPLICATION | NOREPLICATION
    | BYPASSRLS | NOBYPASSRLS
    | CONNECTION LIMIT connlimit
    | [ ENCRYPTED ] PASSWORD 'password' | PASSWORD NULL
    | VALID UNTIL 'timestamp'

ALTER USER name RENAME TO new_name

ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] SET configuration_parameter { TO | = } { value | DEFAULT }
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] SET configuration_parameter FROM CURRENT
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] RESET configuration_parameter
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] RESET ALL

where role_specification can be:

    role_name
  | CURRENT_ROLE
  | CURRENT_USER
  | SESSION_USER

πŸŽ€ the option menu, in vibes πŸŽ€

ok so every flag comes as a lil on/off duo β€” the plain one and the NO-one. iconic honestly:

  • SUPERUSER / NOSUPERUSER β€” the yes flavor / the no flavor πŸ‘‘
  • CREATEDB / NOCREATEDB β€” yes / no πŸ“
  • CREATEROLE / NOCREATEROLE β€” yes / no πŸ¦‹
  • INHERIT / NOINHERIT β€” yes / no πŸ’œ
  • LOGIN / NOLOGIN β€” yes / no πŸ”₯
  • REPLICATION / NOREPLICATION β€” yes / no 🌈
  • BYPASSRLS / NOBYPASSRLS β€” yes / no πŸ’€
  • CONNECTION LIMIT connlimit β€” sets a connlimit value, main character energy
  • [ ENCRYPTED ] PASSWORD 'password' β€” like, ENCRYPTED is optional in brackets, and the password goes in 'password'
  • PASSWORD NULL β€” the other password option, exactly as written
  • VALID UNTIL 'timestamp' β€” with a 'timestamp' 🌸

🫢 the rename moment 🫢

ALTER USER name RENAME TO new_name

⭐ the per-database config era ⭐

all four of these take { role_specification | ALL } and an optional [ IN DATABASE database_name ]:

ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] SET configuration_parameter { TO | = } { value | DEFAULT }
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] SET configuration_parameter FROM CURRENT
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] RESET configuration_parameter
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] RESET ALL

like, SET ... { TO | = } { value | DEFAULT }, or SET ... FROM CURRENT, or RESET configuration_parameter, or just RESET ALL. pick your fighter πŸ’…

🧚 role_specification, explained (sort of) 🧚

role_specification is literally one of these four, no more no less:

  • role_name
  • CURRENT_ROLE
  • CURRENT_USER
  • SESSION_USER

✨ DESCRIPTION ✨

ok so the whole plot twist: ALTER USER is now an alias for ALTER ROLE. that's it. that's the tea 😭 it's giving "we renamed the group chat but it's the same people."


πŸ’– COMPATIBILITY πŸ’–

the ALTER USER statement is a PostgreSQL extension ngl β€” the SQL standard just leaves the definition of users to the implementation. so like, standards said "you figure it out bestie" πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

  • ALTER ROLE β€” that's ALTER_ROLE(7) 🫢 go read it, iykyk

fr fr keep the flags exactly as written β€” ENCRYPTED is in brackets, PASSWORD NULL is its own thing, and connlimit / 'password' / 'timestamp' are placeholders, not literal text πŸ’€

ok that's the whole page, go slay πŸ’…βœ¨

PostgreSQL 17.11 Β· dated 2026 Β· ALTER USER(7) β€” mwah, signed off, periodt πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from