json - 在物化视图中保存 jsonb_each 的输出
问题描述
我在 PG 12 中有一个表“t”-
Id int
Col1 character varying
Data_col jsonb
Data_col 如下所示:
{key1:值 1,key2:值 2,key3:值 3....}
我可以使用以下选择以拖曳形式获取键和值
Select t.id, t.col1, x.key, x.value
From t, jsonb_each_text(t.data_col) x
我想知道是否有办法将上述选择的输出存储到物化视图中?我试过了-
Create materialized view t_mv
As
Select t.id, t.col1, x.key, x.value
From t, jsonb_each_text(t.data_col) x;
但我得到一个错误
error cannot call jsonb_each on a non-object
有任何想法吗?
谢谢
解决方案
你的尝试应该有效。但是,您的查询中的列名不匹配。查询使用 col2,但表是用 col1 定义的。
推荐阅读
- security - 用密码与哈希加密密码
- linux - Bash - 使用给定日期计算
- java - Java JPanel 默认双缓冲似乎并没有摆脱 Choppy 运动
- apache-spark - Spark:从另一个创建新列但不能为空
- url - 我可以用什么来为每个用户生成一个不可猜测的 url?
- ios - 在iOS应用程序中的上下文菜单消失后,索引路径中的选择行不起作用
- html - 如何使用 Angular 视图中的内容创建 PDF?
- vue.js - NativeScript + Vue:让用户选择配色方案
- python - conda $PATH (zsh) 在 Jupyter 实验室中不正确
- ios - Catalina Pod 更新问题:(在检查 pod 版本时)