在pgSQL中删除数组值 [英] Remove array values in pgSQL
本文介绍了在pgSQL中删除数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以从pgSQL中的数组中删除一个值?或者更确切地说,是弹出最后一个值?根据此列表判断,答案似乎是否定的。我可以使用附加的索引指针来获得所需的结果,但这有点麻烦。
Is there a way to remove a value from an array in pgSQL? Or to be more precise, to pop the last value? Judging by this list the answer seems to be no. I can get the result I want with an additional index pointer, but it's a bit cumbersome.
推荐答案
不,我没有认为可以。至少没有写类似下面这样的丑陋的东西:
No, I don't think you can. At least not without writing something ugly like:
SELECT ARRAY (
SELECT UNNEST(yourarray) LIMIT (
SELECT array_upper(yourarray, 1) - 1
)
)
这篇关于在pgSQL中删除数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文