Sunday, May 23, 2010

XMLType - What is it?

While pondering my first meaningful post regarding what it should include and be limited to, I began pondering what an XMLType really is. A CLOB or VARCHAR2 is stored as characters. Numbers are stored as bits and bytes. Dates are an internal Oracle representation. An XMLType though is simply a system-defined opaque type per 11.2 documentation. Depending upon where the XMLType is used, it could be stored in various formats. In the database, it could be represented as a CLOB, binary XML, or object-relational storage. How PL/SQL represents an XMLType is unclear.

Oracle provides many functions to access the data in an XMLType, whether a member function such as .extract or via XMLTable which uses an XMLType. Since the introduction of XMLType in 9.2, the definition in the Oracle documentation has changed slightly over time. Whether this was just documentation clarification or a associated with an underlying structure change is a guess. I suspect the latter given Oracle continues to introduce new DB storage options in 11g.

So for now, I will accept an XMLType as any other basic data type within in Oracle, but I will still continue to wonder how it is represented in PL/SQL and how I can figure it out besides a memory dump. Future post will touch on how to access the data in a XMLType, whether in PL/SQL or the DB along with ways to build XML. For how XML can be stored in the DB, I defer to Marco's blog on that subject where possible.

Information on Data Cartridges (10.2 documentation), as mentioned by Marco in the comment.

1 comment:

  1. Its "not just a datatype", it has many "faces".

    Search for "ku$_opqtype_t" or "sys.xmltype" in packages and scripting in $ORACLE_HOME/rdbms/admin although it is a "system defined opaque type" that makes use internally defined XMLTYPE_LIB which "probably" sometimes uses also the Oracle Data Cartridge Interface (ODCI) sometimes also refered to as Oracle Extendeble Architecture.