How to get hostname in postgresql? Is there any way where I can get hostname/servername in postgresql like @@ServerName in SQL Server?
You need to execute following query to get the hostname:

SELECT boot_val,reset_val
FROM pg_settings
WHERE name='listen_addresses';;