Oracle database XML Data types detailed

Source: Internet
Author: User
Tags stringbuffer

Oracle's XML implementation?
Oracle has implemented XML through the XML DB component of the database tutorial, which is the standard feature of the Enterprise and Standard editions. Oracle XML DB can be easily installed through the database Configuration Assistant (DBCA) or by running a directory script catqm.sql. The XML DB product provides all the features discussed in this article.

To verify that the XML DB is installed, simply run the following SQL:

Select Comp_name from Dba_registry where comp_name like '%xml% '; Comp_name Oracle XML database can also view the XML DB schema and its objects to confirm that Oracle XML DB is installed.

SQL and XML collaboration
The Sql/xml standard is already under development to provide a mechanism that allows us to generate XML from relational queries and, conversely, enables us to submit SQL data from XML documents. Oracle XML DB in Oracle database 10g 2nd releases SQL 2003 and features from the upcoming Sql/xml Standard Edition. The implementation of these standards in Oracle enables us to view XML documents in ways that were not possible in previous SQL standards.

The new data type. The Oracle9i database version 1th introduces a new data type XmlType that allows access to XML documents in the database in SQL while allowing XML developers to use XML standards in their documents. The data type notifies the database that the content is in XML format and allows us to execute the query on the XML document. Use XmlType (rather than a relationship or CLOB implementation) to provide a separate layer between the application and the storage model. This separation allows the data to be moved to a different storage model, not limited to CLOB or relational models. XmlType can be used to create tables, columns, or views. It can also be used as a data type for parameters and variables.

The built-in XML method handles document content, allowing us to create, extract, and index XML data. Indexes can be executed using a B-tree, text index, and a function based index. In fact, XmlType data that is merged with XPath can be used to view documents. This functionality is provided through the Pl/sql and Java APIs. XmlType can be used in Pl/sql, Java with JDBC, and Oracle Data Provider for. Net. This powerful and relatively new data type will be used extensively in this article.

Storage structure. Oracle's XML implementation provides us with the flexibility to store data in two different ways: structured storage and unstructured storage. XmlType data is unstructured when it is stored as a single LOB column and is structured when implemented as an object set.

A specific example of it is the XmlType table, which can be implemented using one of these two storage models. XmlType tables are unstructured when implemented as lobs using the "XmlType store as CLOB" syntax as shown below:
CREATE TABLE table_name of Xmltypexmltype store as CLOB;


public static Boolean Insertlayermetadata (DataSource ds,string xml,string id) throws SQLException, classnotfoundexception{
Boolean flag=false;
String Metadatatablename=dbutil.getlayermetadatatablename (DS);
StringBuffer sql = new StringBuffer ("INSERT into");
Sql.append (Metadatatablename). Append ("(RecordID, Datacol) VALUES (?,?)");
try{
Connection con=dbutil.getconnection (DS);
Logger.info ("Excute sql:" +sql.tostring ());
PreparedStatement Prest = con.preparestatement (sql.tostring ());
XmlType poxml = Xmltype.createxml (con, XML);
Prest.setstring (1, id);
Prest.setobject (2, poxml);
Prest.execute ();
Flag=true;
}
catch (SQLException e) {
Flag=false;
Logger.info (e);
throw new SQLException (e);
}catch (ClassNotFoundException e) {
Flag=false;
Logger.info (e);
throw New ClassNotFoundException (E.getmessage ());
}
return flag;
};

Related Article

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.