小编Gau*_*rav的帖子

Postgres hstore 检查键是否存在且与值不匹配

我在审计表中有一个 hstore 字段,用于存储因操作而更改的所有字段。

在插入时,键updated_byinchanged_fields是 NULL 并且在系统更新时它被设置为system。我想返回未定义键或未定义键的所有行,system但我不知道如何执行此操作。

到目前为止我已经尝试过

select changed_fields -> 'updated_by' 
from audit.logged_actions 
where (changed_fields -> 'updated_by' != 'system' 
       or defined(changed_fields, 'updated_by') = false) 
order by event_id desc
Run Code Online (Sandbox Code Playgroud)

但这不起作用,我不太确定为什么。关于我做错了什么的任何想法?

postgresql hstore

6
推荐指数
1
解决办法
8067
查看次数

标签 统计

hstore ×1

postgresql ×1