The XMLTYPE data type is used to store XML data.

The advantage over storing XML data in a character field is that it checks whether the input values are well-formed, and there are support functions to perform type-safe operations.

As defined by the XML standard, the XML type can store well-formed documents and content fragments. This means that content fragments can have more than one top-level element or character node.

Note Oracle does not support the storage of content fragments in XMLTYPE columns.

Examples

The following example shows the creation and insertion of a row into a table with an XMLTYPE column.

CREATE TABLE books (
    content         XMLTYPE
);

INSERT INTO books VALUES (XMLPARSE (DOCUMENT '<? xml version="1.0"? ><book><title>Manual</title><chapter>...</chapter></book>'));

SELECT * FROM books;

                         content
----------------------------------------------------------
 <book><title>Manual</title><chapter>...</chapter></book>
(1 row)