1. 程式人生 > >Postgre SQL 中Json欄位新增資料

Postgre SQL 中Json欄位新增資料

select json欄位名::jsonb || ‘新增欄位JSon格式’::jsonb from 表名;

例:
select invoice_base_info::jsonb || '{"info":"male"}'::jsonb from nash_invoice;

來源:http://francs3.blog.163.com/blog/static/4057672720157153719971/

以下語句可直接查詢出json格式資料

select array_to_json(array_agg(row_to_json(t))) from (select 欄位1,欄位2,欄位3 from table_a) t


update
nash_invoice_test set invoice_base_info = invoice_base_info::jsonb || '{"info":"male"}'::jsonb