【发布时间】:2011-06-29 19:00:13
【问题描述】:
我们已决定从 PostgreSQL 9.0 数据库中的 OIDs 迁移到使用 bytea 列。我正在尝试将数据从一列复制到另一列,但我无法找出正确的查询。这是我最接近的:
update user as thistable set pkcs_as_bytea = (select array_agg(mylargeobject.data) from
(select * from pg_largeobject where loid = thistable.pkcs12_as_oid order by pageno) as mylargeobject) where thistable.pkcs12 is not null
这给了我以下错误信息:
ERROR: column "pkcs_as_bytea" is of type bytea but expression is of type bytea[]
那么正确的查询是什么?
【问题讨论】:
-
array_agg()返回一个数组,因此错误消息是有意义的。为什么你认为你需要在那里聚合字节? -
我需要将不同 oid 行上的 blob 合并到一个列中。有更好的方法吗?
标签: postgresql oid