This article is also written for describing about how to show current database accessed or being operated in PostgreSQL Database Server and it is related with the management function of PostgreSQL Database Server.
In order to show the current database accessed or being operated, it must be done by executing a specific command which is typed in the PostgreSQL Command Console.
To be able to log in to the PostgreSQL Command Console, there are several things which is needed to be confirmed.
1. Make sure that the PostgreSQL Database Server is properly installed.
2. Make sure that the service of PostreSQL Databse Server is running and active. Read the article titled ‘Check PostgreSQL Service Status’ in this link.
3. Make sure that PostgreSQL Command Console can be accessed and to be logged in for further operation which in the context of this article is for showing the current database accessed in PostgreSQL Command Console. In order to do that, the article titled ‘Check PostgreSQL Service Status’ in this link can be used as further reference. Below is the process of logging in to PostgreSQL Database Server :
[root@hostname ~]# psql -Upostgres Password for user postgres psql (9.4.5) Type "help" for help. postgres=#
So, after successfully logged in to PostgreSQL Command Console, to be able to show the current database being accessed, just execute the following command :
The following are the output of executing the above command for showing the current database accessed :
postgres=# select current_database(); current_database ------------------ postgres (1 row) postgres=#
The actual database to be accessed in the above command execution which can be described in the logged in command execution didn’t specify a specific database name as the additional parameter to point out which database is going to be accessed. But by default even without having to define the database which is going to be accessed by using additional parameter -d, ‘postgres’ database will be presented.