Rename user in PostgreSQL

In this article, we are going to rename user with new name. To rename user, user must have alter user permission or must be superuser.We can not rename the current session user. If we want to rename the current session user, then we need to logout and then login as a different user to run the ALTER USER statement.

Syntax:

ALTER USER USER_NAME RENAME to New_name

Where:
user_name
The name of the user to rename in the PostgreSQL database.
new_name
The new name to assign to the user.

Example: We are going to rename the user ‘john’ to john_ro

ALTER USER john RENAME to john_ro;

Before rename:

bank=# \du john List of roles Role name | Attributes | Member of -----------+------------+-------------- john | | {webreaders}

After Rename
\du john_ro

List of roles Role name | Attributes | Member of -----------+------------+-------------- john_ro | | {webreaders}

Related Posts

CheapSexCams
Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools
%d bloggers like this: