Choose the XMLType storage option

Hi all

I work with an application that will be storing data using an XMLType column. The data being stored is a form with values for an arbitrary number of fields. We have an XSD that defines the different data types that can be stored. So in the document XML, type of the element node corresponds to the type of data stored and 'name' of the node attribute specifies the actual field recording. If a form which includes 2 text fields and 2 fields of type integer may have data like this:
<dataset>
  <textField name="text_field1">Text Data Here</textField>
  <textField name="text_field2">More Text Data Here</textField>
  <integerField name="int_field1">1</integerField>
  <inteferField name="int_field2">2</integerField>
</dataset>
The application will dynamically generate SQL queries to query the different values. Given in each XML document can also be updated / inserted by the application (although this generally will be for one record at a time so the performance for the insert / update is not as much a concern as aggregation queries). In addition, the system is changing for a previous request and that the data stored in a relational way. There will very probably be queries that create relational views out of the column of Type XML.

We currently have this implementation of object-relational storage. Does this sound correct? I can't say if we treat this as semi-structured storage instead. The scheme is well defined, but fields that are stored in each XML document are variable (so we know that data types ahead, just not the real fields). I would like to hear your comments on the type of storage that would be optimal. Any comment is appreciated...

Here is the solution of GOLD

SQL> connect &USERNAME/&PASSWORD
Connected.
SQL> --
SQL> VAR XMLSCHEMA CLOB
SQL> VAR INSTANCE CLOB
SQL> --
SQL> begin
  2          :XMLSCHEMA :=
  3  '
  4          
  5                  
  6                          
  7                                  
  8                                          
  9                                  
 10                          
 11                  
 12          
 13          
 14                  
 15                          
 16                                  
 17                                          
 18                                  
 19                          
 20                  
 21          
 22          
 23                  
 24                          
 25                                  
 26                                  
 27                          
 28                  
 29          
 30  ';
 31    :INSTANCE :=
 32  '
 33       Test1
 34       Test2
 35       1
 36       2
 37  ';
 38  end;
 39  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.00
SQL> begin
  2    DBMS_XMLSCHEMA.registerSchema(
  3                     enablehierarchy  => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE ,
  4                     GENTYPES   => TRUE,
  5                     GENBEAN    => FALSE,
  6                     GENTABLES  => FALSE,
  7                     FORCE      => FALSE,
  8                     OWNER      => USER,
  9                     SCHEMAURL  => 'http://testurl.com/test.xsd',
 10                     SCHEMADOC  => XMLTYPE(:XMLSCHEMA)
 11                  );
 12  end;
 13  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.44
SQL> create table TEST_DATA (
  2    REC_ID                NUMBER  NOT NULL,
  3    REC_DATA          XMLTYPE
  4  )
  5  xmltype REC_DATA
  6  STORE AS OBJECT RELATIONAL
  7  XMLSCHEMA "http://testurl.com/test.xsd"
  8  ELEMENT "dataset"
  9  /

Table created.

Elapsed: 00:00:00.08
SQL> set lines 80
SQL> --
SQL> desc TEST_DATA
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 REC_ID                                    NOT NULL NUMBER
 REC_DATA                                           SYS.XMLTYPE(XMLSchema "http:
                                                    //testurl.com/test.xsd" Elem
                                                    ent "dataset") STORAGE Objec
                                                    t-relational TYPE "dataset66
                                                    4_T"

SQL> --
SQL> begin
  2    DBMS_XMLSTORAGE_MANAGE.renameCollectionTable(USER,'TEST_DATA','REC_DATA','/dataset/textField','TEXT_FIELD_TABLE');
  3    DBMS_XMLSTORAGE_MANAGE.renameCollectionTable(USER,'TEST_DATA','REC_DATA','/dataset/integerField','INT_FIELD_TABLE');
  4  end;
  5  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:01.65
SQL> column NAME format A32
SQL> --
SQL> set lines 80
SQL> --
SQL> desc TEXT_FIELD_TABLE
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
 SYS_XDBBODY$                                       VARCHAR2(4000 CHAR)
 name                                               VARCHAR2(4000 CHAR)

SQL> --
SQL> desc INT_FIELD_TABLE
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
 SYS_XDBBODY$                                       NUMBER(38)
 name                                               VARCHAR2(4000 CHAR)

SQL> --
SQL> create index TEXT_NAME_INDEX on TEXT_FIELD_TABLE("name")
  2  /

Index created.

Elapsed: 00:00:00.02
SQL> create index INT_NAME_INDEX on INT_FIELD_TABLE("name")
  2  /

Index created.

Elapsed: 00:00:00.00
SQL> set autotrace on explain
SQL> set lines 150 pages 100
SQL> --
SQL> insert into TEST_DATA values (1,XMLTYPE(:INSTANCE))
  2  /

1 row created.

Elapsed: 00:00:00.01

Execution Plan
----------------------------------------------------------
Plan hash value: 1

--------------------------------------------------------------------------------------
| Id  | Operation                | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------
|   0 | INSERT STATEMENT         |           |     1 |   100 |     1   (0)| 00:00:01 |
|   1 |  LOAD TABLE CONVENTIONAL | TEST_DATA |       |       |            |          |
--------------------------------------------------------------------------------------

SQL> commit
  2  /

Commit complete.

Elapsed: 00:00:00.00
SQL> select TEXT1, TEXT2, INT1, INT2
  2    from TEST_DATA,
  3         XMLTABLE(
  4           '/dataset'
  5            passing REC_DATA
  6            columns
  7              TEXT1 VARCHAR2(4000) path 'textField[@name="text_field1"]/text()',
  8              TEXT2 VARCHAR2(4000) path 'textField[@name="text_field2"]/text()',
  9              INT1      NUMBER(10) path 'integerField[@name="int_field1"]/text()',
 10              INT2      NUMBER(10) path 'integerField[@name="int_field1"]/text()'
 11           )
 12  /

TEXT1
------------------------------------------------------------------------------------------------------------------------------------------------------
TEXT2
------------------------------------------------------------------------------------------------------------------------------------------------------
      INT1       INT2
---------- ----------
Test1
Test2
         1          1

Elapsed: 00:00:00.07

Execution Plan
----------------------------------------------------------
Plan hash value: 1764375565

--------------------------------------------------------------------------------------------------------
| Id  | Operation                           | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                    |                  |     1 |    20 |     7   (0)| 00:00:01 |
|*  1 |  TABLE ACCESS BY INDEX ROWID BATCHED| TEXT_FIELD_TABLE |     1 |  4014 |     1   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN                  | TEXT_NAME_INDEX  |     1 |       |     1   (0)| 00:00:01 |
|*  3 |  TABLE ACCESS BY INDEX ROWID BATCHED| TEXT_FIELD_TABLE |     1 |  4014 |     1   (0)| 00:00:01 |
|*  4 |   INDEX RANGE SCAN                  | TEXT_NAME_INDEX  |     1 |       |     1   (0)| 00:00:01 |
|*  5 |  TABLE ACCESS BY INDEX ROWID BATCHED| INT_FIELD_TABLE  |     1 |  2025 |     1   (0)| 00:00:01 |
|*  6 |   INDEX RANGE SCAN                  | INT_NAME_INDEX   |     1 |       |     1   (0)| 00:00:01 |
|*  7 |  TABLE ACCESS BY INDEX ROWID BATCHED| INT_FIELD_TABLE  |     1 |  2025 |     1   (0)| 00:00:01 |
|*  8 |   INDEX RANGE SCAN                  | INT_NAME_INDEX   |     1 |       |     1   (0)| 00:00:01 |
|   9 |  TABLE ACCESS FULL                  | TEST_DATA        |     1 |    20 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("NESTED_TABLE_ID"=:B1)
   2 - access("SYS_ALIAS_8"."name"='text_field1')
   3 - filter("NESTED_TABLE_ID"=:B1)
   4 - access("SYS_ALIAS_7"."name"='text_field2')
   5 - filter("NESTED_TABLE_ID"=:B1)
   6 - access("SYS_ALIAS_6"."name"='int_field1')
   7 - filter("NESTED_TABLE_ID"=:B1)
   8 - access("SYS_ALIAS_5"."name"='int_field1')

Note
-----
   - dynamic statistics used: dynamic sampling (level=2)

SQL>

Published by: mdrake on March 14, 2013 11:13

Tags: Database

Similar Questions

  • will choose the manually back option in iTunes backup everything that is on my iPhone to my computer? Including the app data

    Not a problem just a question. I intend to sell my apple iPhone, it's not compatible with my new wireless network. I can't afford to buy an iPhone outright at the moment, but I plan in the future. I want to backup everything on my iPhone to my Mac so that I can restore the data to a new iPhone later. The current iPhone 5 is already set to save important things to iCloud, if I choose the option with a manual backup encryption will be that record everything, including all the data from the app? Sorry if this is a stupid question, I want to just make sure I have everything before you send the iPhone.

    Hello CallRinny,

    I understand that you have a question about your iTunes backups and that you should use. Back on which covers.

    In general, an iTunes backup will cover pretty much everything on your iPhone. The best thing to watch over it, it's what doesn't iTunes back upwards and which covers the encrypted backup. Take a look at the information below to clarify this. I would also do that applications will be recorded in your iTunes library, so when you restore your backup, apps will sync back to the wire in one sitting instead to download on the App Store.

    On safeguards in iCloud and iTunes
    https://support.Apple.com/en-us/HT204136

    backup iTunes

    On your Mac or PC, you can make a backup of your device in iTunes. Synchronize your device with your computer is not the same as performing a backup.

    An iTunes backup includes almost all settings and data from your device. An iTunes backup does not include:

    • Content of the iTunes and App Store or directly downloaded from iBooks PDF files (you can save this content using transfer purchases in iTunes.)
    • Synchronized content from iTunes, as imported MP3s or CDs, videos, books and photos
    • Photos already stored in the cloud, like My Photo Stream and iCloud photo library
    • Tap Settings ID
    • Settings and information Apple pay
    • Data activity, health, and keychain (to save this content, you will need to use iTunes backup encrypted ).

    Learn How to perform backups in iTunes, how to find them on your Mac or PC, and how to delete backups you no longer need.

    Let me know if this clears it for you.

    Take care

  • What is the best storage option [work] for PremPro CC

    Hi people,

    I am currently building a new workstation whose primary use will be to Photoshop and Premiere Pro. I've covered the bases with the following equipment:

    CPU: Intel Core i7 Extreme 4930 K 3 .4GHz Socket 2011

    GPU: 3 GB PNY NVIDIA Quadro graphics card K4000

    Memory: DDR3 Corsair Dominator Quad Channel 2133 * 32 Gb

    OS: Windows 7 Pro 64-bit running an SSD dedicated offshore


    OK, maybe it's a bit excessive, but it gives me flexibility, and a few years grace before some other technology hits the fan!


    Where I struggle is storage.


    Could you please share some examples of life real wrt storage scenarios. Photoshop is quite easy but PremPro is a demanding beast, and I'm not sure whether to implement what I should use. On-board physical space is not a problem [Obsidain 900 d case] but storage can be very expensive, and I'd rather have this right first time. Just to be clear, I'm afraid with storage in a work situation and backup, not external archiving.


    Thank you in advance.


    Lyndon

    http://ppbm7.com/index.php/tweakers-page has several connections to the right information

  • Choose the right storage

    I'm creating a server ESXi white box. It will be a stand-alone box. I have the choice of using RAID 1 or a VelociRaptor(300GB), that it would benefit me the most? I have only a budget for or not both!

    Thank you

    Terry

    The size is not serious and I did not mention the size, I mentioned the spindle speed (7200 RPM against 10KRPM).

    -Matt

    VCP, vExpert, Unix Geek

  • How to change the VM storage profile in vAppTemplate?

    Hello world

    I have a project in front of me to migrate existing virtual machines to a profile of existing storage or the * profile to a profile of newly created storage.  I have determined how to get this done for VMS in vApps already and I am able to update profiles of storage for virtual machines and see them to migrate to the data warehouse associated with the new profile of storage.  I'm currently stuck trying to figure out how to upgrade virtual machines in VAPP models.  I can recover the VAPP model using Get-CIVAppTemplate, but I am not able to browse the virtual machines in.

    So my question is: How can I use on the VMS in a VAPP model to be able to change the profile of storage?

    If not, is there a method to reach my goal (all move to a new storage profile) that I don't see?  I'm afraid I'll make a mess of things in storage by updating virtual machines individually.  If there is a way to lift and move a whole tree (similar to SSMove of Lab Manager), that would be great!

    Thank you

    Jason

    I wasn't always able to solve this problem via PowerCLI.  My eventual solution was manually copy/move the VAPP model in the catalogue and choose the correct storage profile in the process.  Fortunately, we didn't have many models VAPP and it took no more than a few days.

    Jason

  • Ask about the structured storage of XMLTYPE column in Oracle Xml db

    Dear all,

    Version of DB: Oracle 11g (11.2.0.3.0)

    I have a table with an XMLTYPE column with a structured storage.

    CREATE TABLE Orders
        (
        Order_id NUMBER NOT NULL,
        Order_etc VARCHAR2(100),
        Order_desc XMLType NOT NULL
        )
        XMLTYPE Order_desc STORE AS OBJECT RELATIONAL XMLSCHEMA  "http://localhost/public/xsd/order_desc_xsd.xsd" ELEMENT "OrderState";
    

    I then recorded the XSD XML Db schema that is required for the structured storage.

    Before the creation of the table, I had created a table XMLTYPE (db_objects) and was able to use the query to verify that all objects, the XMLTYPE table got broken into when I signed his XSD below.

        SELECT column_name,      
               data_type
        FROM   user_tab_cols
        WHERE  table_name = 'DB_OBJECTS';
    

    And used under query to find data stored in the object-relational structure for my table (DB_OBJECTS) created with definition of XMLTYPE.

      SELECT EXTRACTVALUE(xseq.column_value, '/THISROW/OWNER')       AS owner
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_NAME') AS object_name
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_TYPE') AS object_type
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_ID')   AS object_id
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/CREATED')     AS created
        FROM   db_objects do
         ,      TABLE(XMLSEQUENCE(EXTRACT(VALUE(do), '/ROWSET/THISROW'))) xseq  
        WHERE  ROWNUM <= 10;
    

    Now could someone let me know, How to find how the column of XMLTYPE (Order_desc) was divided between other objects, just as I did for the Table with XMLTYPE (as shown above)?

    Thank you very much.

    First of all, because you are on 11.2, ExtractValue is obsolete and the documentation lists three options to use instead.  Here's an (untested) option

    SELECT owner, object_name, object_type, object_id, created
      FROM db_objects do,
           XMLTable('/ROWSET/THISROW'
                    PASSING do.object_value
                    COLUMNS
                    -- Set data types accordingly
                    owner        VARCHAR2(20) PATH 'owner',
                    object_name  VARCHAR2(20) PATH 'object_name',
                    object_type  VARCHAR2(20) PATH 'object_type',
                    object_id    VARCHAR2(20) PATH 'object_id',
                    created      VARCHAR2(20) PATH 'created');
    

    Secondly, why the column order matter?  You store in a method of object / relational.  As long as the XML is valid per the schema, Oracle will be able to store the data and thus to retrieve later.  How these data are mainly internal Oracle and shouldn't be touched because it can be changed from one version to another.  You can use the schema annotation to control how Oracle cards and stores the XML content, but nothing in there specifies the column order I know.

    It seems several details are missing information which could help others to answer your question as to what you need.

  • When I turn off the option "optimize the iphone storage" in iCloud photos, made my phone automatically re - download all my photos/videos in my phone again?

    I used the option "optimize the iphone storage" on my old phone to save space, but I hated waiting to load when I want to watch them. Now, I clicked on "Download and keep the originals", but I can't tell if my phone is re - download the original photos/videos to iCloud to my phone. What does automatically or are these pictures forever in the version "optimized" on my phone?

    Subsequently, it must download the originals. Synchronization is VERY slow, so it may take some time depending on how many photos you have.

  • Restore the options popup after selecting "Non-action" and choose to use this option, whenever a device is plugged in USB?

    Restore the options popup after selecting "Non-action" and choose to use this option, whenever a device is plugged in USB?

    Hello

    Did you follow the "AutoPlay Repair Wizard"?

    You can follow the link provided in the previous post. Later, check to see if the problem persists.

    Hope the helps of information.

  • In the tab "install windows" to reinstall Vista I have to choose the "country and region", "time and money" and "keyboard", but there are no options to choose in the "country and region.

    Restoration of the system, Vista Home Premium re installation problems.

    After doing a system restore and restart the laptop, I get on the tab "install windows" Reinstall Vista and I have to choose the "country and region", "time and money" and "keyboard", but there is no options to choose from when I click on the tab "country and region" so I cannot proceed with the installation.

    Hi Cbx_banananuts-Walter,

    You can try to reinstall Windows Vista again and check if the problem persists:

    Installation and reinstallation of Windows Vista

    Hope the helps of information.

  • Dell Inspiron 531 - summer pc try to restore factory settings and hit the F8 key after close to a dozen times. I never see the advanced options to choose the factory restore. HELP please...

    tried to restore factory settings and hit the F8 key after close to a dozen times.  I never see the advanced options to choose the factory restore.   HELP please...  I'm following indications out of Dell's web site as well.    UGH

    http://support.Dell.com/support/topics/global.aspx/support/DellCare/contact_us?c=us&l=en&s=Gen&redirect=1

    If you have problems with the process of recovery of Dell, contact Dell at the link above.

    It's Dell recovery, not Microsoft software/process of.

    See you soon.

    Mick Murphy - Microsoft partner

  • I am running Acrobat Pro DC under MacOsSierra and when I want to scan a dokument I can´t choose the option request to the digitization of additional pages. Why?

    I am running Acrobat Pro DC under MacOsSierra and when I want to scan a dokument I can´t choose the option request to the digitization of additional pages. Why?

    Lars Andrae

    If I'm not mistaken you use ICA scanner. This 'Still Prompt pages' option is not available for ICA scans from now. But we are working on that, and will soon be available. I'll put you once its available.

    For now please try the TWAIN driver.

    Thank you.

  • HR crashes whenever I choose the AutoCorrect tab in the Spelling Options

    I get a crash on any project (even the samples provided with HR) HR whenever I choose the AutoCorrect tab in the Spelling Options.

    RoboHelp 2015

    Windows 7 64 bit

    16 GB of Ram (Dell Precision T3600)

    We use Mercurial for source code control.

    It must be something unique to my system because my colleagues do not receive the same thing.

    Ideas on what is the cause? Other tabs and dialog boxes seem to open very well.

    Hmmm, I wonder if you might consider the relocation of RoboHelp.

  • Tools patch problems, do not have the option on my screen to choose the source or destination

    my content aware patch tool has stopped working.  I don't have the option on my screen to choose the source or destination.  I know I did something to her but I don't know what.  any ideas how I can make it work again?  Thank you.

    Hi rojas66,

    Greetings.

    • Make sure you have selected "normal."

    • If this does not work, let us know what changes made since the last time it worked.

    Concerning

    Rohit

  • Need to "Choose a delivery Option" by default for the first shipping option

    I need to know if there is a way to define the "choose a shipping Option" in the shopping cart automatically default to the first shipping option available instead of "Choose a shipping Option" being the default. My site is configured so that the user will have only 1 option shipping for any order submit it.

    Hello

    You could add a small javascript snippet to select the first option (or any delivery option, you need to have previously selected).

  • Hello is anyone here! I need to buy adobe photoshop and illustrator, but I want to pay all at once, is the annual one should I choose? pre paid? Can I choose a less expensive option because I can't really afford it. I was also wondering if I

    Hello is anyone here! I need to buy adobe photoshop and illustrator, but I want to pay all at once, is the annual one should I choose? pre paid? Can I choose a less expensive option because I can't really afford it. I was also wondering if I could buy or install an older version of this program on my Mac from Yosemite, because I need it urgent. Thank you

    Subscription plans are your least expensive option on an annual basis, but do not continue to pay each year in order to continue using them.  The alternative is to buy CS6 which is much more costly in terms of what you pay in the year (day).,... almost all of the costs.

    Buy CS6:
    ----------------------

    http://www.Adobe.com/products/catalog/CS6._sl_id-contentfilter_sl_catalog_sl_software_sl_c reativesuite6.html

Maybe you are looking for

  • The HP printer software update repeats

    I've updated to Yosemite on my iMac and the updated drivers from HP and updates for HP 3525 advantage printer/scanner. All connects and works. AP store finds a new "HP Printer Software Update 3.0" update. I installed this update 10 times in the last

  • Satellite L300 - 17L - cannot install Windows XP

    Help, please. I made the cd of windows xp nLite, but no results. This isn't the start of the dvd. What could I do?I have not found the dll that you were talking about. I downloaded some floppy drive from a link in this forum.I don't know what else to

  • DLLVERSIONINFO2

    I had written the help DLLS of CVI 2009 and earlier that referenced DLLVERSIONINFO2 to query and get the DLL version when executing the calling code.  Now when I compile this code on the same system (Win XP) it can not find a definition for it.  It i

  • Files and folders in root appear in my folder of Documents and office

    It probably happens on the Windows NT-based versions (has happened to me on a XP PC and a PC in 2000 that I intend to upgrade both of them soon). The files and folders of the program directory (C :) root Windows upward in the office and the folder My

  • Why do a DVD/CD-RW-ROM does not recognize blank DVD - RW disc?

    I have a DVD/CD-RW Drive SOHC-5235K who can born CD without any problem, but when I put a DVD - RW to burn a large file, the system and no matter which burning application that I use ask me all the time to introduce a recordable in the drive disc. I