How to Show Available User in PostgreSQL

Posted on

In this article, the content of the article itself is still related with a certain query which is actually a query performed with the output of how to show available user in PostgreSQL Database Server. This is part of SQL Query where is specifically intended and it can only be useful for PostgreSQL Database Server if there is really a difference on how to show the available user with another type or RDBMS (Relational Database Management System) such as MySQL, Oracle, Microsoft SQL Server,etc. So, in order to achieve on how to show available user in PostgreSQL Database Server, there are several steps needed for the output in the form of available user in PostgreSQL Database Server can be presented. Below are those steps :

1. Make sure that PostgreSQL Database Server is installed.

2. Make sure that PostgreSQL Database Server itself, the service which is representing PostgreSQL Database Server currently running. To check the running service of PostgreSQL Database Server, the following article titled ‘How to Check PostgreSQL Database Server’s service status’ in think link which can be used as a reference.

3. Make sure that PostgreSQL Database Server can be accessed and directly passed to the PostgreSQL Command Console as shown below :

[user@hostname ~]# psql -Upostgres 
Password for user postgres:
psql (9.4.5)
Type "help" for help.
postgres=#

After successfully logged in to PostgreSQL Command Console, the following SQL Query Command is used to show the available user in PostgreSQL Database Server connected, accessed or logged in :

select usename from pg_user

The above SQL Query Command can be executed as the following example shown below :

postgres=# select usename from pg_user;
usename
------------
replicator
dbadmin
dbview
postgres
(4 rows)
postgres=#

As shown in the above output, the available user in the accessed, connected or logged in PostgreSQL Database Server is presented and listed. Depends on the environment, the output of the above SQL Command executed can be vary and it can be different one to another. The above output listed 4 (four) user are : replicator, dbadmin, dbviewadmin and postgres.

One thought on “How to Show Available User in PostgreSQL

Leave a Reply