SQL/XML


SQL/XML or XML-Related Specifications is part 14 of the Structured Query Language specification. In addition to the traditional predefined SQL data types like NUMERIC, CHAR, TIMESTAMP,... it introduces the predefined data type XML together with constructors, several routines, functions, and XML-to-SQL data type mappings to support manipulation and storage of XML in a SQL database.

Specification

The specification defines the data type XML, functions for working with XML, including element construction, mapping data from relational tables, combining XML fragments, and embedding XQuery expressions in SQL statements. Functions which can be embedded include XMLQUERY and XMLEXISTS.
Further information and examples of the SQL/XML functions are provided in the external links below.

Standard compliance

The result of Wagner's objective evaluation of the SQL/XML:2006 standard compliance of Oracle 11g Release 1, MS SQL Server 2008 and MySQL 5.1.30 is shown in the following table, to which the data for PostgreSQL 9.1, and IBM DB2 has been added:
Oracle 11g Release 1IBM DB2 9.7MS SQL Server 2008MySQL 5.1.30PostgreSQL 9.1
Datatype XML HighHigh
SQL/XML predicatesHighHigh
SQL/XML functionsHighHighLowHigh
XQuery augmentation

Examples

The sample SQLXML query below has SQLXML type as output:

SELECT XMLELEMENT
)
FROM TMP.CUSTOMER AS cust;

And the output:











Samples are taken from javalobby article.