Postgresql 如何从其他hstore更新现有的hstore值(如果缺少则添加)?

Postgresql 如何从其他hstore更新现有的hstore值(如果缺少则添加)?,postgresql,Postgresql,我在数据库中存储了类似的记录 "BaseCount"=>"6", "EgaisCount"=>"0", "MarkingCount"=>"1", "MercuryCount"=>"2", "gis_work_mod"=>"1", "other"=&g

我在数据库中存储了类似的记录

"BaseCount"=>"6", "EgaisCount"=>"0", "MarkingCount"=>"1", "MercuryCount"=>"2", "gis_work_mod"=>"1", "other"=>"3"
例如,我重新计算了这个hstore的值

"BaseCount"=>"6", "EgaisCount"=>"2"
现在我想选择现有的值BaseCount=>6,egaiscoount=>0,MarkingCount=>1,MercuryCount=>2,gis\u work\u mod=>1,other=>3,并更新只对重新计算的一个BaseCount=>6,egaiscoount=>2中的键进行匹配的键

结果应该是这样的

"BaseCount"=>"12", "EgaisCount"=>"2", "MarkingCount"=>"1", "MercuryCount"=>"2", "gis_work_mod"=>"1", "other"=>"3". Mathes keys updated, other - not
如果出现新键-应将它们添加到结果中。 例如,如果hstore看起来像

"BaseCount"=>"6", "EgaisCount"=>"2", "NewCounts"=>"5"
结果应该是

 "BaseCount"=>"12", "EgaisCount"=>"2", "MarkingCount"=>"1", "MercuryCount"=>"2", "gis_work_mod"=>"1", "other"=>"3", "NewCounts" =>"5"
我尝试了hstore连接-它解决了新的值添加而不是值更新情况

基本连接| |操作符解决了我的问题。我的情况是,我连接了hstore和string。这就是意外行为的原因。

基本串联| |运算符解决了我的问题。我的情况是,我连接了hstore和string。这就是意外行为的原因