XMLTABLE

Syntax



Description of the illustration xmltable.gif

XMLnamespaces_clause::=



Description of the illustration xml_namespaces_clause.gif

XMLTABLE_options::=



Description of the illustration xmltable_options.gif

XML_passing_clause::=



Description of the illustration xml_passing_clause.gif

XML_table_column::=



Description of the illustration xml_table_column.gif

Purpose

XMLTable maps the result of an XQuery evaluation into relational rows and columns. You can query the result returned by the function as a virtual relational table using SQL.

  • The XMLNAMESPACES clause contains a set of XML namespace declarations. These declarations are referenced by the XQuery expression (the evaluated
    XQuery_string), which computes the row, and by the XPath expression in the
    PATH clause of XML_table_column, which computes the columns for the entire
    XMLTable function. If you want to use qualified names in the PATH expressions of the
    COLUMNS clause, then you need to specify the XMLNAMESPACES clause.

  • XQuery_string is a complete XQuery expression and can include prolog declarations.

  • The expr in the XML_passing_clause is an expression returning an
    XMLType or an instance of a SQL scalar data type that is used as the context for evaluating the XQuery expression. You can specify only one
    expr in the PASSING clause without an identifier. The result of evaluating each
    expr is bound to the corresponding identifier in the
    XQuery_string. If any expr that is not followed by an
    AS clause, then the result of evaluating that expression is used as the context item for evaluating the
    XQuery_string.

  • The optional COLUMNS clause defines the columns of the virtual table to be created by
    XMLTable.

    • If you omit the COLUMNS clause, then XMLTable returns a row with a single
      XMLType pseudocolumn named COLUMN_VALUE.

    • The datatype is required unless
      XMLTable is used with XML schema-based storage of XMLType,
      datatype. In this case, if you omit
      datatype, Oracle XML DB infers the data type from the XML schema. If the database is unable to determine the proper type for a node, then a default type of
      VARCHAR2(4000) is used.

    • FOR ORDINALITY specifies that column is to be a column of generated row numbers. There must be at most one
      FOR ORDINALITY clause. It is created as a NUMBER column.

    • The optional PATH clause specifies that the portion of the XQuery result that is addressed by XQuery expression string is to be used as the column content. If you omit
      PATH, then the XQuery expression column is assumed. For example:

      XMLTable(... COLUMNS xyz
      

      is equivalent to

      XMLTable(... COLUMNS xyz PATH 'XYZ')
      

      You can use different PATH clauses to split the XQuery result into different virtual-table columns.

    • The optional DEFAULT clause specifies the value to use when the
      PATH
      expression results in an empty sequence. Its expr is an XQuery expression that is evaluated to produce the default value.

    • See Also:

      Oracle XML DB Developer's Guide for more information on the
      XMLTable function, including additional examples, and on XQuery in general

    • Examples

      The following example converts the result of applying the XQuery '/Warehouse' to each value in the
      warehouse_spec column of the warehouses table into a virtual relational table with columns
      Water and Rail:

    • SELECT warehouse_name warehouse,
      warehouse2."Water", warehouse2."Rail"
      FROM warehouses,
      XMLTABLE('/Warehouse'
      PASSING warehouses.warehouse_spec
      COLUMNS
      "Water" varchar2(6) PATH '/Warehouse/WaterAccess',
      "Rail" varchar2(6) PATH '/Warehouse/RailAccess')
      warehouse2; WAREHOUSE Water Rail
      ----------------------------------- ------ ------
      Southlake, Texas Y N
      San Francisco Y N
      New Jersey N N
      Seattle, Washington N Y

XMLTABLE的更多相关文章

  1. Oracle XMLTable 使用教程与实例

    从Oracle 10g开始,甲骨文公司新增了XQuery和XMLTable两个功能作为处理XML的武器. XMLQuery一样,您可以使用XQuery语言构造XML数据和查询XML和关系数据.你可以使 ...

  2. Oracle中使用虚拟表DUAL或XMLTABLE返回顺序数列

    在Oracle中使用虚拟表DUAL或XMLTABLE返回顺序数列 使用DUAL表和CONNECT BY LEVEL的特殊用法,返回一个1-10的顺序数列,示例代码如下: SELECT LEVEL FR ...

  3. MS SQL巡检系列——检查重复索引

    前言感想:一时兴起,突然想写一个关于MS SQL的巡检系列方面的文章,因为我觉得这方面的知识分享是有价值,也是非常有意义的.一方面,很多经验不足的人,对于巡检有点茫然,不知道要从哪些方面巡检,另外一方 ...

  4. Oracle数据行拆分多行

    工作和学习中常常会遇到一行要分割成多行数据的情况,在此整理一下做下对比. 单行拆分 如果表数据只有一行,则可以直接在原表上直接使用connect by+正则的方法,比如: select regexp_ ...

  5. Oracle行转列、列转行的Sql语句总结

    多行转字符串 这个比较简单,用||或concat函数可以实现  SQL Code  12    select concat(id,username) str from app_userselect i ...

  6. 45 个非常有用的 Oracle 查询语句

    ​ 这里我们介绍的是 40+ 个非常有用的 Oracle 查询语句,主要涵盖了日期操作,获取服务器信息,获取执行状态,计算数据库大小等等方面的查询.这些是所有 Oracle 开发者都必备的技能,所以快 ...

  7. oracle---日期等plsql

    日期/时间 相关查询 1.获取当前月份的第一天 运行这个命令能快速返回当前月份的第一天.你可以用任何的日期值替换 "SYSDATE"来指定查询的日期. SELECT TRUNC ( ...

  8. 如何查看oracle数据库的所有的关键字

    管理员账户登录后,执行以下命令:  select * from v$reserved_words 附上参考: NOMONITORINGRECORDS_PER_BLOCKCASCADEDYNAMIC_S ...

  9. .net之工作流工程展示及代码分享(三)数据存储引擎

    数据存储引擎是本项目里比较有特色的模块. 特色一,使用接口来对应不同的数据库.数据库可以是Oracle.Sqlserver.MogoDB.甚至是XML文件.采用接口进行对应: public inter ...

随机推荐

  1. [BZOJ]1095 Hide捉迷藏(ZJOI2007)

    一道神题,两种神做法. Description 捉迷藏 Jiajia和Wind是一对恩爱的夫妻,并且他们有很多孩子.某天,Jiajia.Wind和孩子们决定在家里玩捉迷藏游戏.他们的家很大且构造很奇特 ...

  2. 《Java技术》第三次作业

    (一)学习总结 1.阅读下面程序,分析是否能编译通过?如果不能,说明原因.应该如何修改?程序的运行结果是什么?为什么子类的构造方法在运行之前,必须调用父 类的构造方法?能不能反过来? class Gr ...

  3. Padding Oracle攻击

    最近在复现LCTF2017的一道题目,里面有一个padding oracle攻击,也算是CBC翻转攻击,这个攻击主要针对CBC加密模式的 网上有关这个攻击的博客文章很多,但是其中有一些细节可能是个人的 ...

  4. Tomcat的安装与配置

    Windows安装Tomcat与启动 安装版安装 安装版长这个样子,下载到电脑上后双击开始安装 双击后出现如下页面,点击 Next> 之后是这个页面,点击 I Agree 之后出现如下页面,点击 ...

  5. 读书笔记-《Maven实战》-关于Maven依赖传递的思考 2018/4/26

    上次读书笔记中,提到了依赖传递.看着依赖传递表,一直在思考为什么会是这样. 先看传递表: compile test provided runtime compile test provided run ...

  6. 初识Redis系列之一:简单介绍

    一:Redis是什么? Redis全称:REmote DIctionary Server(Redis) .Redis是一个由Salvatore Sanfilippo写的key-value存储系统,AN ...

  7. Web网页树形列表中实现选中父节点则子节点全选和不选中父则子全不选

                需要实现的功能:选中父节点对应子节点全选:不选中父节点,对应子节点也不选中 如下图所示,选中车队,对应车队中车辆也全部选中,以实现车队中所有车辆在地图上的显示. 选中cqupt ...

  8. 关于centos版本安装ethereum钱包

    安装go wget https://studygolang.com/dl/golang/go1.9.linux-amd64.tar.gz --no-check-certificatetar -zxvf ...

  9. Python中的数据类型

    计算机顾名思义就是可以做数学计算的机器,因此,计算机程序理所当然地可以处理各种数值.但是,计算机能处理的远不止数值,还可以处理文本.图形.音频.视频.网页等各种各样的数据,不同的数据,需要定义不同的数 ...

  10. Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad

    [题意概述] 在一个十字路口 ,给定红绿灯的情况, 按逆时针方向一次给出各个路口的左转,直行,右转,以及行人车道,判断汽车是否有可能撞到行人 [题目分析] 需要在逻辑上清晰,只需要把所有情况列出来即可 ...