在oracle中的表名中添加单引号

时间:2017-10-26 18:16:45

标签: oracle

我试图在表格中添加单行

我的查询设计如下

select 
    upper(listagg(table_nm,',') within group (order by table_nm)) as table_nm 
from
    db.tb
where
    subject_area='TLS'

并输出

TLS_TASK,TLS_USER

但我希望输出为

'TLS_TASK','TLS_USER'

请帮我这个

2 个答案:

答案 0 :(得分:3)

您需要再提供3个引号来附上报价。引号内的''代表单引号。

     SELECT Upper(Listagg(''''
                     ||table_nm
                     ||'''', ',')
               within GROUP (ORDER BY table_nm)) AS table_nm
FROM   db.tb
WHERE  subject_area = 'TLS';  

答案 1 :(得分:1)

'

之前和之后简单地连接引用table_nm
select 
    upper(listagg(''''||table_nm||'''',',') within group (order by table_nm)) as table_nm 
from
    db.tb
where
    subject_area='TLS'