In this article, we will see how to rename role or user in PostgreSQL.
The alter role/user statement is used to rename role or user in PostgreSQL.
Syntax:
ALTER ROLE/USER ROLE_NAME RENAME TO NEW_NAME;
Examples:
1. Rename role to new name
In the following example, we are going to rename the role ‘salesgroup’ to salesrole.
alter role salesgroup rename to salerole;
2. Rename user act_new to accountant.
alter user act_new rename to accountant;
So, in this article we have seen how to rename the role or user to new name.