【发布时间】:2018-08-29 18:20:21
【问题描述】:
我有一个包含 2 个字段的表格:
table documents
docu_id uuid
attachments jsonb
attachments jsonb 列的示例数据为:
[
{
"size": 10,
"attach_id": "d3a21f904068"
},{
"Size": 0.143,
"attach_id": "5ba4b285565b"
}
]
我已经看到很多关于如何根据字段名称更新/删除 jsonb 的示例,但是是否可以从 匿名数组 中删除 匿名对象 其中@ 987654324@
delete from documents
where docu_id = "Y"
and
where attachments @> '[{"attach_id": "X"}]'
【问题讨论】:
-
您想从表格中删除整个行吗?还是只是数组中的一个元素?
-
@a_horse_with_no_name 只是数组中的元素。从附件 jsonb 数组中删除 attach_id = "X"
标签: postgresql postgresql-9.3 postgresql-9.4