PostgreSQL query to find the host name

subhash-DBA 105 Reputation points
2025-01-10T03:46:57.2766667+00:00

HI Team,

I am looking for a PostgreSQL command/query (not Azure CLI )that i can run in Azure PostgreSQL flexible server to get the server name.

currently i can get this info using the below psql command "\conninfo", but this command works only in the PSQL prompt and not part of stored procedures/code that runs from applications.

Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. NIKHILA NETHIKUNTA 4,100 Reputation points Microsoft Vendor
    2025-01-10T07:17:10.15+00:00

    @subhash-DBA
    Thank you for the question and for using Microsoft Q&A platform.

    As per my understanding you are trying to get the Postgre SQL server's name using a query.
    Can you please let me know what application are you trying to run? This would help me to understand the query better.
    User's image

    The above queries are used to fetch the database name, server's IP address and port number, which can help identify the server and also the version of the server. Hope this helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.