How to rename PostgreSQL role name

In this article, we will see how to rename PostgreSQL role name.

The ALTER ROLE statement also allows for a change in the name of the role: the RENAME
clause allows for a role to be substituted by another unique role name.

Syntax to rename PostgreSQL role:

ALTER ROLE name rename to new_name;

Examples:

Lets verify the list of roles using below query.

select usename from pg_user;

How to rename PostgreSQL role name

Now rename the role(user) davids to david

alter role davids rename to david;

So in this article, we have seen syntax and example to rename role or user name in PostreSQL.