当前位置:首页 > 开发 > 数据库 > 正文

Binary XML Data Storage in 11g

发表于: 2013-10-29   作者:czmmiao   来源:转载   浏览次数:
摘要: Oracle 11g New Features TipsIn previous versions of Oracle, two Extensible Markup Language (XML) storage options were available: unstructured, or CLOB, and storage and structured, or schema-based.&nbs

Oracle 11g New Features Tips
In previous versions of Oracle, two Extensible Markup Language (XML) storage options were available: unstructured, or CLOB, and storage and structured, or schema-based.  In Oracle 11g, binary XML has been added as a new storage option.
Unstructured storage treats an XML document as a large object and stores the file in the database without being aware of the content.  This option has the best insertion and deletion performance, but the worst relational access and consumption of disk space.
Structured storage requires prior registration of the XML schema and inserts an XML document into an object-relational structure.  This storage option has the best query performance and disk space consumption, but the highest cost during initial insertion.  This high cost is caused because during insertion, the document is shredded and stored into database objects created during the registration of the XML schema.
Binary XML, the new storage option introduced in 11g, stores the document in a post-parse binary format designed specifically for XML.  This option will likely be the best choice for most XML requirements.  The additional binary storage offers insertion performance comparable to unstructured storage, yet query and disk space performance that is comparable to structured storage.  Unlike structured storage, the benefits of binary XML are not dependent on schema registration.  This is due to the option of registering a binary XML schema to have schema based binary XML tables.  However, one limitation remains in that a registered XML schema cannot be shared between a binary XML and object relational table.
The best strategy when choosing how to manage XML content is to first try the binary storage option and evaluate whether the performance is acceptable.  If the relational access performance is not acceptable, then try the structured storage option.  The reason that binary storage is preferred is that it is easy to use and requires the least amount of maintenance because schema registration is not required.  Binary XML type columns are also easier to use in non-XMLType tables since performance is not dependent on the creation of indexes. 
To use binary storage, the XML table must be created with the following syntax:
SQL> CREATE TABLE BINARY_XML_TABLE OF XMLType XMLTYPE STORE AS BINARY XML
  2  /
Table created.
Consider the following XML document for order transactions:
test_document.xml
<?xml version="1.0"?>
<order>
    <customer>
        <name>Customer ABC</name>
        <ccNum>1234123412341234</ccNum>
    </customer>
    <orderLines>
       <item>
        <item_id>108</item_id>
        <item_name>ORACLE 11G NEW FEATURES BOOK ED1.0</item_name>
        <quantity>1</quantity>
        <unitPrice>$38.00</unitPrice>
      </item>
      <item>
        <item_id>109</item_id>
        <item_name>ORACLE TUNING GUIDE ED1.0</item_name>
        <quantity>1</quantity>
        <unitPrice>$22.00</unitPrice>
      </item>
   </orderLines>
   <receipt>
        <subtotal>$60.00</subtotal>
        <salesTax>$4.80</salesTax>
        <total>$64.80</total>
   </receipt>
</order>
Insert this document into the binary XML table using the following syntax:
SQL> insert into BINARY_XML_TABLE values (XMLTYPE(BFILENAME ('XML_DIR','test_document.xml'),nls_charset_id('AL32UTF8')));
1 row created.
After insertion, the document is immediately available for relational access.  
SELECT
   extractValue(value(b),'/order/customer/name')  customer_name,
   extractValue(value(d),'/item/item_id')  item_id,
   extractValue(value(d),'/item/quantity')  quantity,
   extractValue(value(d),'/item/unitPrice')  unit_price,
   extractValue(value(b),'/order/receipt/subtotal')  subtotal,
   extractValue(value(b),'/order/receipt/salesTax')  salesTax,
   extractValue(value(b),'/order/receipt/total')  total
from
BINARY_XML_TABLE a
,TABLE(XMLSequence(Extract(object_value,'/order'))) b
,TABLE(XMLSequence(Extract(value(b),'/order/orderLines'))) c
,TABLE(XMLSequence(Extract(value(c),'/orderLines/item'))) d;
CUSTOMER_NAME  ITEM_ID QUANTITY UNIT_PRICE SUBTOTAL SALESTAX TOTAL
-------------- ------- -------- ---------- -------- -------- ------
Customer ABC   108     1        $38.00     $60.00   $4.80    $64.80
Customer ABC   109     1        $22.00     $60.00   $4.80    $64.80
As demonstrated above, the syntax for relational access to a binary XML table does not change from other storage options.

 

参考至:http://www.dba-oracle.com/t_11g_new_binary_xlm_storage.htm

如有错误,欢迎指正

邮箱:czmcj@163.com

Binary XML Data Storage in 11g

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
Bigtable: A Distributed Storage System for Structured Data Fay Chang, Jeffrey Dean, Sanjay Gh
第一次告诉大家有关SharePoint 2007中的外部二进制数据存储(External Binary Storage)的相关信息
90% 是Heap table Cluster 集群表, index-organized table: 就是把索引和表 和二为一了. partitione
一般GridFS需要两次查询:第一次是查询文件的元数据,第二次是查询文件的内容。因此,如果你使用Gri
一般GridFS需要两次查询:第一次是查询文件的元数据,第二次是查询文件的内容。因此,如果你使用Gri
app需要兼容多种分辨率的设备,一般的情况下,布局文件,都会提供多套出来,供自动匹配。 但调试修
Silverlight–Displaying Tookit Charts from XML Data Every now and again I revisit my obsessio
一.Data Recovery Advisor(DRA) 说明 1.1 DRA 说明 DRA在遇到错误时会自动收集数据故障信息。此外
今天将flex的Deshboard引入工程运行时报错“Unable to load data/pod.xml”错误,google后发现有人遇
今天写程序发现一个问题,就是XML中报出android.view.InflateException异常,可能的原因有: 1.XML中
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号