Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL 9.3: Query to get hostname,port number and username

I want to write a query which should result me the following details:

  1. Host,
  2. Port,
  3. Username.

Like we get in the PgAdmin as shown in the below picture:

enter image description here

As per a_horse_with_no_name said in this answer gives me only port number.

like image 646
MAK Avatar asked Dec 27 '25 16:12

MAK


1 Answers

SELECT CURRENT_USER usr
      ,inet_server_addr() host -- use inet_client_addr() to get address of the remote connection
      ,inet_server_port() port -- use inet_client_port() to get port of the remote connection

System Information Functions

like image 120
Vivek S. Avatar answered Dec 31 '25 12:12

Vivek S.