This is one of the article relates on the management of PostgreSQL Database Server. The function which is the focus of the database management specifically in PostgreSQL Database Server is about how to show current user in PostgreSQL Database Server. The function for showing current user in PostgreSQL Database Server only works after logging in into PostgreSQL Command Console.
The main function in the management of PostgreSQL Database Server to show current user in the PostgreSQL Command Console after logging in is just to make sure that the SQL command executed further later on will be executed by the correct user.
Before logging in to the PostgreSQL Command Console, make sure that PostgreSQL Database Server is installed and the service is currently running. In order to check the service, just read the article titled ‘Check PostgreSQL Service Status’ in this link.
After checking the service and the service itself is currently running, just logged in to the PostgreSQL Database Server. In order to logged in to PostgreSQL Command Console, just read the article titled ‘PostgreSQL Database Access from Command Line in Linux’ in this link.
After logging in to PostgreSQL Comamnd Console, the SQL command executed in PostgreSQL Command Console itself where in this context is to show current user in PostgreSQL Database Server is shown below :
The SQL command executed above is displayed in a real example below :
[root@hostname ~]# psql -Upostgres -P psql (9.4.5) Type "help" for help. postgres=# select current_user(); current_user -------------- postgres (1 row) postgres=#
As shown in the above command and also the output generated from executing the above command, it can be seen that the current user logged in is ‘postgres’. It can be understood that the current user logged in is ‘postgres’ since the psql command executed in the first place has the value of ‘postgres’ attached as part of the additional parameter -U which stands for User.