【问题标题】:XMLTYPE Extract multiple paths / IndexingXMLTYPE 提取多个路径/索引
【发布时间】:2014-01-24 12:45:08
【问题描述】:

我有一个表“TEST”,其中有一个 CLOB 列“XML”(DB Oracle 11),其中保存了 xml 的内容。

在此列中,您可以找到包含此类内容的示例行

1 行

<xml>
     <identification>Test1</identification>
<xml>

2 行

<xml>
    <identificationNumber>Test2</identificationNumber>
<xml>

正常的提取是这样的:

    Select
    XMLTYPE("TEST"."XML").EXTRACT('//identification/text()').getStringVal()
    From "XML"

1.问题

如何从两个路径中提取?由于两者名称相同,例如只是 xml 中的一个错误。

2。问题

虽然在一次选择中有很多提取物,但为了提高性能,索引可能会更好,还是?

我怎样才能像上面那样索引一个提取?

【问题讨论】:

    标签: xml oracle indexing extract xmltype


    【解决方案1】:

    问题 1

    如果节点在层次结构中的相同位置,您可以使用以下内容:

    SQL> create table test (xml clob)
      2  /
    
    Table created.
    
    SQL> insert into test
      2  select '<xml>
      3       <identification>Test1</identification>
      4  </xml>' from dual union all
      5  select '<xml>
      6      <identificationNumber>Test2</identificationNumber>
      7  </xml>' from dual
      8  /
    
    2 rows created.
    
    SQL> select XMLTYPE("TEST"."XML").EXTRACT('/xml//text()').getStringVal()
      2    from test
      3  /
    
    XMLTYPE("TEST"."XML").EXTRACT('/XML//TEXT()').GETSTRINGVAL()
    -----------------------------------------------------------------------------------
    Test1
    Test2
    
    2 rows selected.
    

    问题 2

    在这个例子中,索引可能对你没有任何好处。但总的来说,这里有一些关于 XML 索引的链接:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多