识别主机名和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
--------------------------------------------------------------
C4210gR21 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')
--------------------------------------------------------------
marge1 row selected.SQL> SELECT SYS_CONTEXT('USERENV','HOST') FROM dual;SYS_CONTEXT('USERENV','HOST')
--------------------------------------------------------------------
marge1 row selected.SQL> SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual;SYS_CONTEXT('USERENV','IP_ADDRESS')
--------------------------------------------------------------
192.168.2.31 row selected.SQL> SELECT SYS_CONTEXT('USERENV','SERVER_HOST') FROM dual;SYS_CONTEXT('USERENV','SERVER_HOST')
--------------------------------------------------------------
C4210gr21 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
------------------------------------------------
C4210gR21 row selected.
4、VSESSIONTheVSESSION The VSESSION view contains the following host information for all database sessions:
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\MARGE1 row selected.
识别主机名和IP地址相关推荐
- 《Linux防火墙(第4版)》——1.5 主机名和IP地址
本节书摘来自异步社区<Linux防火墙(第4版)>一书中的第1章,第1.5节,作者:[美]Steve Suehring(史蒂夫 苏哈林)著,更多章节内容可以访问云栖社区"异步社区 ...
- 包含了主机名到ip地址的映射关系的文件是什么 ?
包含了主机名到ip地址的映射关系的文件是什么 ? A. /eto/HOSNAME B./eto/hosts c./eto/resolv.conf D./eto/net [解析] /etc/host ...
- oracle+查询主机地址,oracle函数:获取Internet主机名和ip地址
您可能感兴趣的话题: Oracle 核心提示:oracle函数获取Internet主机名和ip地址 Oracle包utl_inaddr 作用:用于取得局域网或Internet环境中的主机名和IP地址. ...
- printf 地址_C程序显示主机名和IP地址
查找本地计算机的主机名和IP地址的方法有很多.这是使用C程序查找主机名和IP地址的简单方法. 我们将使用以下功能: gethostname() :gethostname函数检索本地计算机的标准主机名. ...
- Android修改主机名和IP地址问题
Android修改主机名和IP地址问题 搜了一下找到如下方法,不知到能用不: Android手机系统如何修改hosts文件 由于某些原因,可能需要修改 hosts 文件指定域名到对应的 IP 地址.A ...
- 域用户桌面显示计算机名,用Bginfo设置域客户端桌面显示主机名和IP地址信息
老林同学那天给老师部署了个作业,说在维护工作中,经常要问用户他们的主机名或IP地址是多少,大多数用户难以找到这些信息,如果能将主机名显示在"我的电脑"下面就好了,结果,这个作业小徐 ...
- 5.1.3 配置主机名和IP地址的映射关系
5.1.3 配置主机名和IP地址的映射关系 在CentOS 6.8服务器中,主机名和IP地址的映射关系可以在/etc/hosts文件中进行配置.这里可以通过vim编辑器对/etc/hosts文件进行编 ...
- CentOS(Linux)配置主机名和IP地址的映射关系
1.修改主机名 #查看主机名 hostname #修改主机名 hostname yuanke01 2.配置主机名和IP地址的映射关系 #打开/etc/hostvim /etc/host#添加主机名和I ...
- Python获取本地mac地址、主机名、IP地址
1 在windows系统,命令行输入 ipconfig /all 此处获得mac地址. 2 在Python中获取mac地址 import uuid mac = uuid.UUID( int=uuid. ...
最新文章
- python如何调用参数配置文件_python参数设置
- Oracle 异常 ORA-01861: literal does not match format string(字符串格式不匹配)
- Fast implementation/approximation of pow() function in C/C++
- linux 当前活动用户,如何在Linux上自动记录所有用户的终端会话活动
- devc++鼠标变成了光标_游戏鼠标到底能不能提升你的实力?
- .so 依赖目录 cmake_CMAKE最全实战(2)
- gradle和maven区别
- SAP License:赛锐信息访谈启示录(五)
- 标准BT.656并行数据结构
- Hive DDL DML
- 泛微oa系统什么框架_泛微移动办公OA系统走进江苏国曜信息科技有限公司
- eclipse如何添加Memory Analyzer
- python爬取必应的壁纸
- 服务器两广豪杰维护,逆水寒11月22日更新到几点 世界boss即将掉落逆水之寒
- 对不起,今年我真的不敢去拜年了。。。
- 风控贷款---年龄因素
- 产业高地、价值洼地,雨花一流营商环境是如何炼成的?
- 如何恢复未保存的Excel文件
- 【解决】ubuntu用vim编辑时退格键和上下左右键失灵的问题
- frontpage css,在Frontpage 中定义网页CSS样式
热门文章
- usnews美国大学计算机科学排名,美国USNews美国大学计算机专业排名
- AR 相机扫描效果实现
- 前端开发,用 css3 做一个求婚小动画
- synplify编译报错
- 企业微信自建引用接口调用报错[ErrorCode:301002]not allow operate another agent with this accesstoken
- 编译原理--语法分析:LR(1)
- stanford cs230 课程笔记
- ## 项目第十五天 ##
- python开发ps插件_你还在用PS?Python 20行代码批量抠图
- TEM一维正演matlab,大地电磁学chp3一维正演.ppt