XMLTYPE is a data type for storing XML data. Unlike character fields, XMLTYPE validates that input is well-formed XML and provides type-safe operations for working with XML content.
Per the XML standard, XMLTYPE stores both well-formed documents and content fragments. Content fragments can have more than one top-level element or character node.
Examples
Create a table with an XMLTYPE column
CREATE TABLE books (
content XMLTYPE
);Insert XML data
Insert a well-formed document:
INSERT INTO books VALUES (
XMLPARSE (DOCUMENT '<?xml version="1.0"?><book><title>Manual</title><chapter>...</chapter></book>')
);Query XML data
Retrieve all rows:
SELECT * FROM books;Expected output:
content
----------------------------------------------------------
<book><title>Manual</title><chapter>...</chapter></book>
(1 row)Oracle compatibility note
Note Oracle does not support storing content fragments in XMLTYPE columns. If you are migrating from Oracle, review any inserts that use
XMLPARSE (CONTENT ...) and verify they behave as expected in PolarDB for Oracle.该文章对您有帮助吗?