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:

      1. XMLTable(... COLUMNS xyz

      is equivalent to

      1. 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:

      1. SELECT warehouse_name warehouse,
      2. warehouse2."Water", warehouse2."Rail"
      3. FROM warehouses,
      4. XMLTABLE('/Warehouse'
      5. PASSING warehouses.warehouse_spec
      6. COLUMNS
      7. "Water" varchar2(6) PATH '/Warehouse/WaterAccess',
      8. "Rail" varchar2(6) PATH '/Warehouse/RailAccess')
      9. warehouse2;
      10.  
      11. WAREHOUSE Water Rail
      12. ----------------------------------- ------ ------
      13. Southlake, Texas Y N
      14. San Francisco Y N
      15. New Jersey N N
      16. 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. poj 2065 高斯消元(取模的方程组)

    SETI Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1735   Accepted: 1085 Description ...

  2. 谷歌开发者:看可口可乐公司是怎么玩转TensorFlow的?

    在这篇客座文章中,可口可乐公司的 Patrick Brandt 将向我们介绍他们如何使用 AI 和 TensorFlow 实现无缝式购买凭证. 可口可乐的核心忠诚度计划于 2006 年以 MyCoke ...

  3. flask jQuery ajax 上传文件

    1.html 代码 <div> <form id="uploadForm" enctype="multipart/form-data" > ...

  4. c# 虚拟路径转化为物理路径

    string strPhycicsPath= Server.MapPath(path);

  5. rabbitMQ权限相关命令

    权限相关命令为: (1) 设置用户权限 rabbitmqctl  set_permissions  -p  VHostPath  User  ConfP  WriteP  ReadP (2) 查看(指 ...

  6. 40道Java初中级算法面试题

    [程序1]   题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第四个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? 1.程序分析:   兔子的规律为数 ...

  7. fastDFS 安装 配置 使用

    fastDFS 安装 配置 使用 关于安装 本文采用的是源码的安装方式,其他安装方式请自行百度 简单介绍 1.背景 FastDFS是一款开源的.分布式文件系统(Distributed File Sys ...

  8. 转:Kafka 客户端TimeoutException问题之坑

    原文出自:http://www.jianshu.com/p/2db7abddb9e6 各种TimeoutException问题 会抛出org.apache.kafka.common.errors.Ti ...

  9. brew的MAC安装

    1.介绍 brew是一个软件包管理工具,类似于centos下的yum或者ubuntu下的apt-get,非常方便,免去了自己手动编译安装的不便 brew 安装目录 /usr/local/Cellar ...

  10. 用命令直接在两台ubuntu之间传输数据

    首先查看openssh-server是否启动: ps -e | grep ssh 如果没有任何提示则是没有启动: sudo /etc/init.d/ssh -start 启动进程.若提示找不到命令则需 ...