从Postgresql表的column字段中提取键,值

时间:2018-07-19 20:22:01

标签: json postgresql

 id   |                   columns                    |         timestamp          | query_id             |               task_id
-------+----------------------------------------------+----------------------------+----------------------+---------------------------
     1 | {"uid": "112", "name": "redis-server"}       | 2018-07-18 18:45:39.045387 |                    1 |                         2
     2 | {"uid": "0", "name": "celery"}                 | 2018-07-18 18:45:39.047671 |                    1 |                         2
     3 | {"uid": "111", "name": "post"}           | 2018-07-18 18:45:39.048218 |                    1 |                         2
     4 | {"uid": "111", "name": "post"}           | 2018-07-18 18:45:39.048732 |                    1 |                         2

希望通过查询语法从json中提取UID和NAME的常规值

1 个答案:

答案 0 :(得分:0)

您可以使用JSON运算符->>。即:

-x