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. [bzoj1558][JSOI2009]等差数列

    题目:给定n个数,m个操作,每次给一段区间加一个等差数列或者询问一段区间至少要用多少个等差数列来表示.$n,m\leqslant 10^{5}$ 题解:老套路,维护差分数组,修改操作变成了两个单点加和 ...

  2. [3.24校内训练赛by hzwer]

    来自FallDream的博客,未经允许,请勿转载,谢谢. ----------------------------------------------------------------------- ...

  3. 笔记13 AOP中After和AfterReturning的区别

    AOP中 @Before @After @AfterThrowing@AfterReturning的执行顺序 public Object invoke(Object proxy, Method met ...

  4. 笔记5 bean的作用域

    1. Spring定义了多种作用域,可以基于这些作用域创建bean,包括: 单例(Singleton):在整个应用中,只创建bean的一个实例.(默认) 原型(Prototype):每次注入或者通过S ...

  5. C#之Action和Func的用法

    以前我都是通过定义一个delegate来写委托的,但是最近看一些外国人写的源码都是用action和func方式来写,当时感觉对这很陌生所以看起源码也觉得陌生,所以我就花费时间来学习下这两种方式,然后发 ...

  6. sqlserver 按照特定值排序查询结果

    select * from t_ss_student order by case when xm like '林%' then 1 else 2 end asc; 姓林的会排在前面

  7. Java8——快速入门手册(学习笔记)

    github博文传送门 Java8特性学习笔记 Java8中新增了许多的新特性,在这里本人研究学习了几个较为常用的特性,在这里与大家进行分享.(这里推荐深入理解Java 8用于理解基础知识)本文分为以 ...

  8. Exception 的 toString() 方法和 getMessage() 方法的区别

    Exception 的 toString() 方法和 getMessage() 方法的区别: 在开发的过程中打印错误日志时尽量使用e.toString() 方法, 因为当错误为空指针时 e.getMe ...

  9. python解析json文件之简介

    一.JSON简介 JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于JavaScript(Standard ECMA-262 3rd Edition ...

  10. delphi 面向对象实用技能教学一(递归)

    本例使用类与TList相结合,用简洁的方法,实现了一个 HTML 解析与格式化功能.所用到的知识点如下:1.类的提前申明2.TList用法3.String的指针操作4.单例设计5.递归用法 编程是综合 ...