`

Binary XML Data Storage in 11g

 
阅读更多

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

分享到:
评论

相关推荐

    Web Microanalysis of Big Image Data

    6.6 Storage and data structure for big images. 16 6.6.1 Storage for big images. 17 6.6.2 Data structures for big images. 22 6.6.3 Summary. 23 6.7 Parallel computations over big image data. 23 ...

    NativeXml-master

    fixed problems in binary xml. Consequence: New binary xml version v2. * NativeXml (and binary xml) now supports xml-stylesheet correctly * binary xml now supports doctype correctly * fixed attribute...

    Android基础 Content Provider

    - 注册Content Provider:在AndroidManifest.xml文件中声明Content Provider,指定它的权威URI和对应的类名。 - 实现UriMatcher:用于解析不同的URI请求并调用对应的方法。 ### 3、通过内容提供者完成CRUD操作 - *...

    Java2核心技术卷I+卷2:基础知识(第8版) 代码

    Reading and Writing Binary Data 23 ZIP Archives 32 Object Streams and Serialization 39 File Management 59 New I/O 65 Regular Expressions 75 Chapter 2: XML 87 Introducing XML 88 Parsing an ...

    Power Query M Reference Microsoft Docs.pdf

    6. **Other Utility Functions**:包括`Binary`函数系列,用于处理二进制数据,如`Binary.Buffer`用于创建二进制缓冲区,`Binary.Combine`用于合并二进制数据,还有`Csv.Document`和`Xml.Document`分别处理CSV和XML...

    Big Data Glossary-大数据术语

    Amazon Simple Storage Service (S3) 是一个对象存储服务,提供了99.999999999%的数据持久性,适用于备份、存档以及网站托管等多种用途。 **4.2 Hadoop 分布式文件系统(Hadoop Distributed File System, HDFS)** ...

    javacv-platform-1.3.3-src

    CvMemStorage storage = CvMemStorage.create(); // The OpenCVFrameRecorder class simply uses the CvVideoWriter of opencv_videoio, // but FFmpegFrameRecorder also exists as a more versatile ...

    php.ini-development

    should be disabled, as enabling it may result in issues when generating XML ; documents, however this remains supported for backward compatibility reasons. ; Note that this directive does not control...

    VB编程资源大全(英文源码 控件)

    &lt;END&gt;&lt;br&gt;10 , Scroller.zip This is a Control Container, it's like a frame control but it lets you scroll the content up and down...&lt;END&gt;&lt;br&gt;11 , TrayArea.zip This control lets you add your icon ...

    ZendFramework中文文档

    5.4. Zend_Config_Xml 6. Zend_Console_Getopt 6.1. Getopt 简介 6.2. 声明 Getopt 规则 6.2.1. 用短语法声明选项 6.2.2. 用长语法声明选项 6.3. 读取(Fetching)选项和参数 6.3.1. 操作 Getopt 异常 6.3.2...

    2021-2022计算机二级等级考试试题及答案No.12328.docx

    - **十进制(Decimal):**这是最常用的一种数制,基数为10,即由0至9十个数字组成。 - **八进制(Octal):**八进制的基数为8,使用0到7这八个数字。 - **十六进制(Hexadecimal):**十六进制的基数为16,除了0到9...

    [Go语言入门(含源码)] The Way to Go (with source code)

    1.2.8 Programming in Go......................................................................................10 1.2.9 Summary.............................................................................

    The way to go

    1.2.8 Programming in Go......................................................................................10 1.2.9 Summary.............................................................................

Global site tag (gtag.js) - Google Analytics