[ADMIN] Some questions on PostgreSQL 9.6 JSONB

Поиск
Список
Период
Сортировка
От Wei Shan
Тема [ADMIN] Some questions on PostgreSQL 9.6 JSONB
Дата
Msg-id CAFe9ZTqKPihYG6LsPqpfSmD2dK7D1jhxLTwe+7YE7x5emL-D1Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: [ADMIN] Some questions on PostgreSQL 9.6 JSONB
Список pgsql-admin
Hi all,

I have some questions on JSONB on PostgreSQL 9.6.

I have a table with just a single column of JSONB datatype.

The following record was inserted into the table:

INSERT INTO json_data values ( '{"id": "00043","name": "i am a boy","national_id": "SZ123123123","address": {"current": "current_address","prev":"prev_address"} ,"phone_number": "+44d765223424","dob": 123213123, "age": "87", "nationality": "british", "account_status": false, "account_type": "123", "account_balance": "123120392183091.99", "sub_account": "[00042,00043]", "days_till_next_bill": "1503513254", "photo": "bytes"} ');

I would like to update the account_balance to 1.

UPDATE json_data set "data" = jsonb_set('{"id": "00043","name": "i am a boy","national_id": "SZ123123123","address": {"current": "current_address","prev":"prev_address"} ,"phone_number": "+44d765223424","dob": 123213123, "age": "87", "nationality": "british", "account_status": false, "account_type": "123", "account_balance": "123120392183091.99", "sub_account": "[00042,00043]", "days_till_next_bill": "1503513254", "photo": "bytes"}'::jsonb, '{account_balance}', '1'::jsonb, false);

Is this the most efficient way to do it? I'm not sure because this is basically replacing the entire JSON object instead of updating a single field.

Thanks!




--
Regards,
Ang Wei Shan

В списке pgsql-admin по дате отправления:

Предыдущее
От: Don Seiler
Дата:
Сообщение: Re: [ADMIN] Standby Mechanics: WAL vs Streaming
Следующее
От: Keith
Дата:
Сообщение: Re: [ADMIN] Some questions on PostgreSQL 9.6 JSONB