This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am showing a command for getting the name of your Current or Connected Database of PostgreSQL.
If any of your scripts are specific to a particular database, before running it we should check the database name.
When you connect to the SQL Editor of PostgreSQL, by default you connected to a specific database.
But when you are going to run any DBA maintenance script or any other major script which is generic for all databases, we must check the database name in that script.
In the logic of PostgreSQL Function, you can handle this programmatically by creating a user input parameter so dynamically you can use the script for multiple/specific database.
Check the current or connected database name:
1 |
SELECT current_database(); |
Leave a Reply