Below query gives server ip. But i need machine ip. Please suggest how to get machine ip and machine name.
select inet_client_addr();
I used below query to get machine name but did not work.
SELECT * FROM pg_stat_activity
WHERE client_addr = inet_client_addr()
Your question is not clear, but if you want the IP address of the database server you are connected to, you could try
SELECT inet_server_addr();
But remember that every computer has several IP addresses. If you connected to localhost
, you will get 127.0.0.1
or ::1
, depending whether you use IPv4 or IPv6.
There is no function to figure out all IP addresses of the database server. If you need that, you'd have to write a function in a sufficiently powerful unrestricted language like PL/PerlU.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With