Technical suggestions on using XMLType for Synchronous content in Address Book Database Design

Source: Internet
Author: User

Technical suggestions on using XMLType for Synchronous content in Address Book Database Design

Zhou Peng

2005-02-20

 

Oracle 9i (9.0.1) Support for XML Technology

XML built-in features provided by Oracle 9i:

Oracle 9i supports the XMLType type, which is an object type defined by the Oracle 9i system. XMLType has built-in functions that provide powerful functions such as creation, search, and indexing of XML push.

You can use SQL functions to dynamically generate XML documents. These functions include SYS_XMLGEN, SYS_XMLGEN, and PL/SQL package DBMS_XMLGEN.

XML features

Description

XMLType

1. XMLType is a data type defined by the oracle system. The system predefines internal functions to access XML data. You can execute the following tasks:

2. Create an XMLType column and use built-in functions on the XMLType column.

To create PL/SQL functions and stored procedures, you can use XMLType as a parameter or as a return parameter.

3. Store, index, and process XML data on the XMLType column.

 

DBMS_XMLGEN

DBMS_XMLGEN is a PL/SQL package. It converts the results of an SQL query to the standard xml format, returns an XMLTye type or CLOB, and DBMS_GEN is implemented in C language, placed in the database kernel. The DBMS_XMLGEN package and DBMS_XMLQuery package have similar functions.

SYS_XMLGEN

XMLGEN is an SQL function used to generate XML in SQL queries. DBMS_XMLGEN and other package operations are at the query level,

SYS_XMLGEN converts a value, object type, and XMLType instance into an XML document. The type returned by SYS_XMLGEN is XMLType.

 

Sys_xmlmetadata

Sys_xml1_is an aggregate function that is aggregated on the XMLType.

Sys_xml.pdf aggregates all input XML document fragments and adds the labels of the previous layer by connecting XML fragments to generate a single XML document

 

UriTypes

The UriType family can store and query Ur-refs in the database. SYS. UriType is an abstract data type, which provides the function to access the data pointed to by the URL. SYS. HttpUriType and SYS. DBUriType are child types of UriType. SYS. HttpUriType stores HTTP URLs and DBUriType stores the intra-database reference. You can define the child type of your SYS. UriType.

 

 

 

How to Use XMLType to create an XMLType column:

Create table warehouses (

Warehouse_id NUMBER (3 ),

Warehouse_spec SYS. XMLTYPE,

Warehouse_name VARCHAR2 (35 ),

Location_id NUMBER (4 ));

Insert XMLType column data

INSERT into warehouses (warehouse_id, warehouse_spec) VALUES (1001, sys. XMLType. createXML (

& Lt; Warehouse whNo = "100" & gt;

<Building> Owned </Building>

</Warehouse> '));

The input parameter of createXML can be any expression or type CLOB that returns varchar2. CreateXML can check whether XML is suitable, but it cannot check the XML validity.

 

Use SQL query on the XMLType Column

SELECT

W. warehouse_spec.extract ('/Warehouse/Building/text ()'). getStringVal ()

"Building"

FROM warehouses w

Warehouse_spec is an XMLType column, and Extract () is the operation in the above function

The query result is as follows:

Building

-----------------

Owned

Update an XMLType Column

UPDATE warehouses SET warehouse_spec =

Sys. XMLType. createXML (

& Lt; Warehouse whono = "200" & gt;

<Building> Leased </Building>

</Warehouse> '));

Delete An XMLType Column

Delete from warehouses e

WHERE e. warehouse_spec.extract ('// Building/text ()'). getStringVal ()

= 'Leased ';

For more information, see Application Developer's Guide-XML.

 

Advantages of using XMLType to store synchronization information in the address book

1. Data Authenticity:

The XMLType field can be added, modified, deleted, and indexed like other types. We

You can save the raw data you have synchronized.

2. Functional Scalability:

The synchronized information is the XML self-description content, which is complex and diverse:

The xml descriptions of different u data are different;

The formats of different content transmitted by u are different. The formats of data such as vcard and vcalendar are different.

It is difficult to use traditional table technology to solve such problems.

If XML conversion technology is used, a unified interface will be provided for different types in the future.

Disadvantages of using XMLType to store synchronization information in the address book

We are not very familiar with the query performance of XMLType.

 

XML-related technologies

1. Techniques for converting XML files into objects

JDK 1.4 provides the technology of saving objects as XML files and converting XML files into objects.

Refer to java. beans. Encode

Java. beans. Decode

2. dynamically convert xml instances into objects

Refer to org. jibx. runtime .*

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.