Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Binary XML Data Storage in 11g

Oracle 11g New Features Tips by Donald BurlesonJune 29, 2015

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. 

 

This is an excerpt from the new book Oracle 11g New Features: Expert Guide to the Important New Features by John Garmany, Steve Karam, Lutz Hartmann, V. J. Jain, Brian Carr.

You can buy it direct from the publisher for 30% off.

 

 
��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.