gpt4 book ai didi

json - postgres : how to convert hstore to JSON datatypes

转载 作者:行者123 更新时间:2023-12-03 20:20:01 24 4
gpt4 key购买 nike

我正在尝试编写迁移以将现有的 hstore 列转换为 JSON(不是 JSONB)。

我尝试了不同的解决方案 json USING cast(hstore_column as json) ,在 github 上找到了一些函数,但没有真正奏效。

主要问题是没有直接转换,其次是即使我将列转换为文本作为中间步骤,我也需要将默认列值更改为 json。

有人已经这样做了吗?

最佳答案

你可以简单地使用

alter table my_table alter column h_store_column type json using hstore_to_json(h_store_column)

当然,您首先需要删除列上不符合 json 数据类型的任何默认设置。

关于json - postgres : how to convert hstore to JSON datatypes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33732529/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com