-1

Is it possible to query the name and the IP address of a Postgres server (where the Postgres DBMS is running) (not the hostname or host IP address).

Also, I was looking for a query to get the name of each instance running on the server.

like here the instance test.

I could not find anything to get this information via any query.

I am working on a project for my degree, and I really appreciate any help.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
alaa
  • 1
  • 2
  • A PostgreSQL server has no name. There is no database query to return data about a different instance on the same machine. Besides, there are too many questions in your question. Please focus. – Laurenz Albe Nov 28 '22 at 06:54
  • OK , I did not know that you can only ask one question. thanks anyway – alaa Nov 28 '22 at 09:35
  • You should spend a few minutes to take the [Tour](https://stackoverflow.com/tour) and review [ask]. – Belayer Nov 28 '22 at 20:58

1 Answers1

0

You can get the IP address of the PostgreSQL server with

SELECT inet_server_addr();

Note that the result depends on the network interface you used to connect (the server may have several different IP addresses).

There is no query to that can give you information about other instances running on the same machine; each instance has no idea about any other instances.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263