oracle怎么在数据拼接中文,Oracle 拼接列数据的方法

本文通过示例介绍如何在Oracle中拼接中文角色ID,包括使用wm_concat()和sys_connect_by_path()函数,以及如何处理排序和权限问题。
摘要由CSDN通过智能技术生成

保存在这里,方便自己以后查看 (⊙_⊙) ╮(╯▽╰)╭

我们可以先这样创建一张需要的临时表(Role 表):

select 'role_01' as role_id, 'admin' as role_category from dual

union all

select 'role_02' as role_id, 'admin' as role_category from dual

union all

select 'role_03' as role_id, 'normal' as role_category from dual

union all

select 'role_04' as role_id, 'normal' as role_category from dual

union all

select 'role_05' as role_id, 'normal' as role_category from dual

union all

select 'role_06' as role_id, 'normal' as role_category from dual

union all

select 'role_07' as role_id, 'normal' as role_category from dual

union all

select 'role_08' as role_id, 'normal' as role_category from dual

表结构:

a6b03fdbf8803e6d219b1838efca48e8.png

现在我们要根据 role_category 分组,把相同 role_category 下的 role_id 连接起来,就是列 role_id 转成行,大家可能很容易想到使用 wm_concat() 方法来进行:

select role_category,

wm_concat(role_id) as role_id_list

from (

select 'role_01' as role_id, 'admin' as role_category from dual

union all

select 'role_02' as role_id, 'admin' as role_category from dual

union all

select 'role_03' as role_id, 'normal' as role_category from dual

union all

select 'role_04' as role_id, 'normal' as role_category from dual

union all

select 'role_05' as role_id, 'normal' as role_category from dual

union all

select 'role_06' as role_id, 'normal

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值