小编ram*_*ams的帖子

PostgreSQL不需要空数组

我使用postgreSQL 9.1.在我的数据库中有一个看起来像的表

id | ... | values
-----------------------
1  | ... | {1,2,3}
2  | ... | {}
Run Code Online (Sandbox Code Playgroud)

其中id是一个整数,values是一个整数数组.数组可以为空.

我需要删除此列表.如果我查询

select id, ..., unnest(values)
from table
Run Code Online (Sandbox Code Playgroud)

我得到三行id = 1(正如预期的那样)并没有id = 2的行.有没有办法得到像这样的结果

id  | ... | unnest
-------------------
1   | ... | 1
1   | ... | 2
1   | ... | 3
2   | ... | null
Run Code Online (Sandbox Code Playgroud)

即一个查询,其中还包含具有空数组的行?

arrays postgresql

13
推荐指数
2
解决办法
7921
查看次数

标签 统计

arrays ×1

postgresql ×1