oracle多行字段拼接,超长内容

项目场景:

oracle数据库 根据用户需求需要进行规定格式内容导出

问题描述

由于进行表关联,查询出的数据比较多,但是需要合并到一个字段,使用 其他拼接函数都不能满足需求

原因分析:

select listagg(role_name, ',') within group(order by role_name) from table_role

由于数据库对字符串的最大支持长度为 4000 所以使用处理 varchar 的函数都会报长度问题。

解决方案:

使用下面这种方式,可以满足字段处理要求

xmlagg(xmlparse(content name||',' wellformed) order by update_time desc).getclobval() as name

猜你喜欢

转载自blog.csdn.net/u012129030/article/details/125924888