postgres如何更新追加和剪切字符串
postgres how to update append and cut string
我有一个 table 如下所示:
id | name | type | info | ksid | iv
----+-------+------+-------------------------------------------------------+------+----------------------------------
1 | local | 1 | "keyId"=>"1234", "server"=>"http://10.10.13.10/keys/" | | 30646462653237643965373830343334
如何将字符串附加到信息,以便信息值为
"keyId"=>"1234", "server"=>"http://10.10.13.10/keys/", "period"=>"0"
以及改完之后如何改回
"keyId"=>"1234", "server"=>"http://10.10.13.10/keys/"
您可以通过以下方式增值:
UPDATE yourtable SET info = info || '"period"=>"0"' :: hstore WHERE id = 1;
并删除:
UPDATE yourtable SET info = delete(info, 'period') WHERE id = 1;
我有一个 table 如下所示:
id | name | type | info | ksid | iv
----+-------+------+-------------------------------------------------------+------+----------------------------------
1 | local | 1 | "keyId"=>"1234", "server"=>"http://10.10.13.10/keys/" | | 30646462653237643965373830343334
如何将字符串附加到信息,以便信息值为
"keyId"=>"1234", "server"=>"http://10.10.13.10/keys/", "period"=>"0"
以及改完之后如何改回
"keyId"=>"1234", "server"=>"http://10.10.13.10/keys/"
您可以通过以下方式增值:
UPDATE yourtable SET info = info || '"period"=>"0"' :: hstore WHERE id = 1;
并删除:
UPDATE yourtable SET info = delete(info, 'period') WHERE id = 1;