在db2中查找xml类型列的数据大小

时间:2021-09-20 16:30:07

I have a table which has a column of data type xml. I want to find the size of data inserted by user in that column. DB2 shows the length of that column is 0.

我有一个表有一个数据类型为xml的列。我想找到用户在该列中插入的数据大小。 DB2显示该列的长度为0。

How can i find the size of data that is present in column of type xml in a table in DB2 database?

如何在DB2数据库的表中找到xml类型列中存在的数据大小?

1 个解决方案

#1


6  

Had the same problem.

有同样的问题。

As XML in DB2 is a transient datatype it is stored in its hierarchical form. So what you have to do is to serialize the xml-content (because it's stored in it's "parsed" form) and output it into a serialized data type (e.g. a CLOB).

由于DB2中的XML是一种瞬态数据类型,因此它以分层形式存储。所以你要做的就是序列化xml-content(因为它存储在它的“解析”形式中)并将其输出为序列化数据类型(例如CLOB)。

Take for example the table xmltable with the column content which is of type XML:

例如,表格xmltable包含XML类型的列内容:

SELECT xmltable.*, XMLSERIALIZE(xmltable.content AS CLOB(20M))
    FROM xmltable

Be sure to initialize the CLOB large enough, otherwise you'll get an error 22001.

一定要初始化CLOB足够大,否则你会收到22001错误。

#1


6  

Had the same problem.

有同样的问题。

As XML in DB2 is a transient datatype it is stored in its hierarchical form. So what you have to do is to serialize the xml-content (because it's stored in it's "parsed" form) and output it into a serialized data type (e.g. a CLOB).

由于DB2中的XML是一种瞬态数据类型,因此它以分层形式存储。所以你要做的就是序列化xml-content(因为它存储在它的“解析”形式中)并将其输出为序列化数据类型(例如CLOB)。

Take for example the table xmltable with the column content which is of type XML:

例如,表格xmltable包含XML类型的列内容:

SELECT xmltable.*, XMLSERIALIZE(xmltable.content AS CLOB(20M))
    FROM xmltable

Be sure to initialize the CLOB large enough, otherwise you'll get an error 22001.

一定要初始化CLOB足够大,否则你会收到22001错误。