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. Mybatis Generator 代码生成配置

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...

  2. 在Spring Boot中使用Spring Security实现权限控制

    丢代码地址 https://gitee.com/a247292980/spring-security 再丢pom.xml <properties> <project.build.so ...

  3. Java线程池使用和常用参数

    多线程问题: 1.java中为什么要使用多线程使用多线程,可以把一些大任务分解成多个小任务来执行,多个小任务之间互不影像,同时进行,这样,充分利用了cpu资源. 2.java中简单的实现多线程的方式 ...

  4. 566. Reshape the Matrix

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...

  5. vuex存储和本地存储(localstorage、sessionstorage)的区别

    1.最重要的区别:vuex存储在内存,localstorage则以文件的方式存储在本地 2.应用场景:vuex用于组件之间的传值,localstorage则主要用于不同页面之间的传值. 3.永久性:当 ...

  6. ubuntu 14.04 64位 安装Opencv3.1.0 (包含opencv_contrib模块)

    写在前边: 据官方说法,目前还不是太稳定的算法模块都在opencv_contrib里边,由于不稳定,所以不能在release版本里发行,只有在稳定以后才会放进release里边.但是这里边有很多我们经 ...

  7. Oracle中查询和删除相同记录的3种方法

    --创建测试表 )); ,'); ,'); ,'); ,'); ,'); ,'); commit; select * from test; --查询相同记录 ); select id,name fro ...

  8. ACM 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活

    Problem Description 急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品, ...

  9. PHP date() 函数

    实例 格式化本地日期和时间,并返回格式化的日期字符串: <?php // Prints the dayecho date("l") . "<br>&qu ...

  10. 使用GDAL进行RPC坐标转换

    使用GDAL进行RPC坐标转换 对于高分辨率遥感卫星数据而言,目前几乎都提供了有理函数模型(RFM)来进行图像校正(SPOT系列提供了有理函数模型之外还提供了严格轨道模型).对遥感影像进行校正目前最常 ...