How to Show Available User with Role in PostgreSQL

Posted on

This article is also an article related on several function exist in PostgreSQL Database Server. The function which is becoming the focus of the writing in this article is about how to show available user with role in PostgreSQL Database Server. In order to achieve it on how to show available user with role in PostgreSQL Database Server, there are several steps which is needed to be performed or executed as shown below :

1. Check whether PostgreSQL Database Server has already been installed. PostgreSQL Database Server must be installed at the first place.

2.It is important to check the already installed PostgreSQL Database Server is currently running or the service representing¬† PostgreSQL Database Server is active and it is prepared to receive incoming connections. The available article which is properly explained on how to check the status of the running service of PostgreSQL Database Server can be shown in the article titled ‘How to Check PostgreSQL Database Server’s service status’ in this link.

  1. If the service of PostgreSQL Database Server is currently running. Try to connect, access and logged in to the PostgreSQL Command Console as shown below :

[root@hostname ~]# psql -Upostgres 
psql (9.4.5)
Type "help" for help.

postgres=#

After successfully logged in to PostgreSQL Database Server, just execute the following command to display the available user name along with the role possessed by those users in the listed output as follows :

\du

For an example :

postgres=# \du
List of roles
Role name  |Attributes                                    | Member of
-----------+----------------------------------------------+----------+
postgres   |Superuser, Create role, Create DB, Replication| {}
replicator | Replication                                  | {}
dbadmin    |                                              | {}
dbview     | No inheritance                               | {}
test       | No inheritance, Cannot login                 | {}
postgres=#

As the output shown above, the output itself can be different and it can be vary from one to another depends on the environment and the user available in the PostgreSQL Database Server. There are five users with their associated roles. Each of the roles from each user can be different from one to another depends on the role which is granted before.

Leave a Reply