ALTER_USER(7pg17)
π 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 aconnlimitvalue, main character energy[ ENCRYPTED ] PASSWORD 'password'β like,ENCRYPTEDis optional in brackets, and the password goes in'password'PASSWORD NULLβ the other password option, exactly as writtenVALID 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_nameCURRENT_ROLECURRENT_USERSESSION_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'sALTER_ROLE(7)π«Ά go read it, iykyk
fr fr keep the flags exactly as written βENCRYPTEDis in brackets,PASSWORD NULLis its own thing, andconnlimit/'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
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms