XML Value Encoding and the Encoding Declaration - Teradata Vantage NewSQL Engine - 16.20

Teradata Vantage™ XML Data Type

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1140-162K

This table shows what the encoding and encoding declaration will be based on the return data type of the XML value.

Return Type of XML Value Encoding Encoding Declaration
XML type 
(in record/indicator mode) UTF-8
  • If a document is retrieved in its entirety, and if it originally had an encoding declaration, the encoding declaration is preserved.
  • If there was no original encoding declaration, none is added (no encoding declaration is interpreted as UTF-8 by the parser according to the standard).
CLOB or VARCHAR
(in field mode, or when XMLSERIALIZE is called with CLOB or VARCHAR target type) The encoding of the document received will match the session character set in use.
  • If a document is retrieved in its entirety, and if it originally had an encoding declaration, the encoding declaration is preserved.
  • If there was no original encoding declaration, none is added.
BLOB or VARBYTE 
(when XMLSERIALIZE is called with BLOB or VARBYTE target type) The encoding of the XML value will be as specified by the user via the ENCODING clause in the XMLSERIALIZE function call. It is UTF-8 if an encoding is not specified. The encoding declaration is as specified by user via the ENCODING clause or none.

If the XML values are returned as XML, CLOB, or VARCHAR values, there is potential for mismatch between the actual encoding of the XML value and its encoding declaration. You can instruct the parser via parser-provided APIs to override the encoding declaration in the XML document based on external knowledge, such as knowing the session character set in use.