Arrays Postgres将文本数组转换为Int数组

Arrays Postgres将文本数组转换为Int数组,arrays,postgresql,Arrays,Postgresql,为了使用Unnest函数,我需要将列表转换为数组 这是我的文本类型列表。它是这个函数()的输出: 我使用 array[108,109,110,114,115,116,117,156,157,200,201,205] 结果为文本[]类型: "{"108,109,110,114,115,116,117,156,157,200,201,205"}" 对于这种数组,unnest函数不起作用,所以我想转换为Int数组 谢谢如果我理解正确,您需要这个(无需转换为INT): 选择concat('{','1

为了使用Unnest函数,我需要将列表转换为数组

这是我的文本类型列表。它是这个函数()的输出:

我使用

array[108,109,110,114,115,116,117,156,157,200,201,205]
结果为文本[]类型:

"{"108,109,110,114,115,116,117,156,157,200,201,205"}"
对于这种数组,unnest函数不起作用,所以我想转换为Int数组


谢谢

如果我理解正确,您需要这个(无需转换为
INT
):

选择concat('{','108109110114115117171515617020201205','}')::int[]
"{"108,109,110,114,115,116,117,156,157,200,201,205"}"
select unnest( string_to_array('108,109,110,114,115,116,117,156,157,200,201,205', ',' ) )
with the_data(str) as (
    select '108,109,110,114,115,116,117,156,157,200,201,205'::text
)

select elem
from the_data,
unnest(string_to_array(str, ',')) elem;

 elem 
------
 108
 109
 110
 114
 115
 116
 117
 156
 157
 200
 201
 205
(12 rows)