識別主機名和IP地址
文章來源:https://oracle-base.com/articles/misc/identifying-host-names-and-addresses
Identifying Host Names and IP Addresses
識別主機名和IP地址
This article presents a mixed bag of Oracle functionality relating to the identification of host names and IP addresses for Oracle clients and servers.
該篇文章展示了一系列關於識別Oracle客戶端和伺服器主機名和IP地址的方法。
1、UTL_INADDR
2、SYS_CONTEXT
3、V$INSTANCE
4、V$SESSION
1、UTL_INADDR
The UTL_INADDR package was introduced in Oracle 8.1.6 to provide a means of retrieving host names and IP addresses of remote hosts from PL/SQL.
The GET_HOST_ADDRESS function returns the IP address of the specified host name.
SQL> SELECT UTL_INADDR.get_host_address('bart') FROM dual;
UTL_INADDR.GET_HOST_ADDRESS('BART')
--------------------------------------------------------------
192.168.2.4
The IP address of the database server is returned if the specified host name is NULL or is omitted.
如果主機名未指定預設返回資料庫伺服器所在IP地址。
SQL> SELECT UTL_INADDR.get_host_address from dual;
GET_HOST_ADDRESS
--------------------------------------------------------------
192.168.2.5
An error is returned if the specified host name is not recognized.
如果指定的主機名不存在則返回錯誤。
SQL> SELECT UTL_INADDR.get_host_address('banana') from dual;
SELECT UTL_INADDR.get_host_address('banana') from dual
*
ERROR at line 1:
ORA-29257: host banana unknown
ORA-06512: at "SYS.UTL_INADDR", line 19
ORA-06512: at "SYS.UTL_INADDR", line 40
ORA-06512: at line 1
The GET_HOST_NAME function returns the host name of the specified IP address.
SQL> SELECT UTL_INADDR.get_host_name('192.168.2.4') FROM dual;
UTL_INADDR.GET_HOST_NAME('192.168.2.4')
--------------------------------------------------------------
bart
The host name of the database server is returned if the specified IP address is NULL or omitted.
SQL> SELECT UTL_INADDR.get_host_name FROM dual;
GET_HOST_NAME
--------------------------------------------------------------
C4210gR2
1 row selected.
An error is returned if the specified IP address is not recognized.
SQL> SELECT UTL_INADDR.get_host_name('1.1.1.1') FROM dual;
SELECT UTL_INADDR.get_host_name('1.1.1.1') FROM dual
*
ERROR at line 1:
ORA-29257: host 1.1.1.1 unknown
ORA-06512: at "SYS.UTL_INADDR", line 4
ORA-06512: at "SYS.UTL_INADDR", line 35
ORA-06512: at line 1
2、SYS_CONTEXT
The SYS_CONTEXT function is able to return the following host and IP address information for the current session:
SYS_CONTEXT函式可返回當前會話的以下資訊:
1) TERMINAL - An operating system identifier for the current session. This is often the client machine name.
2) HOST - The host name of the client machine.
3) IP_ADDRESS - The IP address of the client machine.
4) SERVER_HOST - The host name of the server running the database instance.
The following examples show the typical output for each variant.
SQL> SELECT SYS_CONTEXT('USERENV','TERMINAL') FROM dual;
SYS_CONTEXT('USERENV','TERMINAL')
--------------------------------------------------------------
marge
1 row selected.
SQL> SELECT SYS_CONTEXT('USERENV','HOST') FROM dual;
SYS_CONTEXT('USERENV','HOST')
--------------------------------------------------------------------
marge
1 row selected.
SQL> SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual;
SYS_CONTEXT('USERENV','IP_ADDRESS')
--------------------------------------------------------------
192.168.2.3
1 row selected.
SQL> SELECT SYS_CONTEXT('USERENV','SERVER_HOST') FROM dual;
SYS_CONTEXT('USERENV','SERVER_HOST')
--------------------------------------------------------------
C4210gr2
1 row selected.
3、V$INSTANCE
The HOST_NAME column of the V$INSTANCE view contains the host name of the server running the instance.
SQL> SELECT host_name FROM v$instance;
HOST_NAME
------------------------------------------------
C4210gR2
1 row selected.
4、V
1) TERMINAL - The operating system terminal name for the client. This is often set to the client machine name.
2) MACHINE - The operating system name for the client machine. This may include the domain name if present.
The following examples show the typical output for each column.
SQL> SELECT terminal, machine FROM v$session WHERE username = 'TIM_HALL';
TERMINAL MACHINE
------------------------------ -------------------------------
MARGE ORACLE-BASE\MARGE
1 row selected.
相關文章
- 更改solaris IP地址和主機名(轉)
- Oracle中獲取主機名和IP地址Oracle
- linux22-IP地址和主機名Linux
- 得到計算機的主機名和IP地址 (轉)計算機
- 在cmd中獲取ip地址和主機名
- solaris 主機修改主機名 ip地址 步驟
- 14IP地址、主機名、域名
- 更改solaris主機名及ip地址(zt)
- Python 基礎練習 —— 獲取本機 Mac 地址、ip 地址和主機名PythonMac
- Solaris - 修改IP和主機名
- gethostbyname() -- 用域名或主機名獲取IP地址
- owb修改主機名和IP地址啟動報錯解決方法
- Solaris 10.5配置主機名、IP地址、閘道器
- C#獲取IP和主機名C#
- 【Solaris】Solaris10作業系統 修改ip地址、主機名作業系統
- 在InstallShield中透過主機名獲取IP地址 (轉)
- IP地址、子網掩碼、網路號、主機號、網路地址、主機地址
- 【VIP】調整RAC虛擬IP地址(VIP)及虛擬主機名
- Java獲取本機名稱、本機MAC地址、IP地址JavaMac
- 遠端控制篇:透過機器名得到IP地址 透過IP地址得到機器名 (轉)
- HP-UX修改主機IP地址UX
- docker 指定IP地址、與主機同網段IPDocker
- 網路裝置配置與管理————11、配置主機名、時鐘、IP地址
- (轉)【VIP】調整RAC虛擬IP地址(VIP)及虛擬主機名
- 主機名修改為IP地址後LISTENER無法監聽到例項
- Linux7修改主機IP及主機名Linux
- 查詢SQLServer的客戶端IP和主機名SQLServer客戶端
- 通過IP地址和子網掩碼,如何計算出網路地址、廣播地址和主機數?
- mac地址和ip地址有什麼區別Mac
- Asp.net MVC獲取訪問系統的客戶端計算機的主機名和IP地址ASP.NETMVC客戶端計算機
- 計算機網路知識總結:有關IP地址、子網掩碼、網路號、主機號、網路地址、主機地址以及ip段/數字的概念及筆試題計算機網路筆試
- Linux中配置網路地址,主機名Linux
- python獲取本機IP、mac地址、計算機名PythonMac計算機
- qt獲取本機IP地址、計算機名、網路連線名、MAC地址、子網掩碼、廣播地址QT計算機Mac
- 徹底弄懂ip掩碼中的網路地址、廣播地址、主機地址
- RHL6.4 修改IP,主機名指令碼指令碼
- 【TCP/IP】IP地址分類和特殊IP地址TCP
- 印表機ip地址哪裡看 印表機ip地址和埠檢視方法介紹