【发布时间】:2016-01-12 14:52:36
【问题描述】:
我使用的是 PostgreSQL 9.4。
最初,我的 USERS 表中有一个 DETAILS 字段,它是 HSTORE 字段类型。
我很容易使用以下方法将该列类型从 HSTORE 更新为 JSONB:
ALTER TABLE users ALTER COLUMN details TYPE jsonb USING CAST(details AS jsonb)
我现在面临的问题是我必须编写回滚,但我无法找到从 JSONB 转换为 HSTORE 的方法。 p>
我尝试过使用:
ALTER TABLE users ALTER COLUMN details TYPE hstore USING CAST(details AS hstore)
得到:
ERROR: cannot cast type jsonb to hstore
有人可以帮我解决这个问题吗?
提前致谢, 以西结
【问题讨论】:
标签: json postgresql casting hstore jsonb