커넥션 생성후 SQL 문을 이용하여 내 세션 정보를 알아볼수 있습니다.
쿼리 자체 의미는 설명하지 않겠습니다. 설명이 필요없으니깐요^^
1) 아래는 로컬로 접속을때의 결과 입니다.
[postgres@pg-00:/var/lib/pgsql]$ psql -U scott -d scottdb
Null display is "NULL".
Timing is off.
Pager usage is off.
psql (9.2.2)
Type "help" for help.
scott@[local]:5432:scottdb]
SQL> select inet_server_port(), current_database(), current_user, current_schema, inet_server_addr();
inet_server_port | current_database | current_user | current_schema | inet_server_addr
------------------+------------------+--------------+----------------+------------------
NULL | scottdb | scott | public | NULL
(1 row)
scott@[local]:5432:scottdb]
SQL>
2) 다음은 호스트명을 명시적으로 지정하여 접속했을때의 정보입니다.
결과값 차이를 잘 음미해보세요.
[postgres@pg-00:/var/lib/pgsql]$ psql -h 10.10.10.22 -U scott -d scottdb
scott@10.10.10.22:5432:scottdb]
SQL> select inet_server_port(), current_database(), current_user, current_schema, inet_server_addr();
inet_server_port | current_database | current_user | current_schema | inet_server_addr
------------------+------------------+--------------+----------------+------------------
5432 | scottdb | scott | public | 10.10.10.22
scott@10.10.10.22:5432:scottdb]