Appearance
JSONB
Prerequisite: To create a
JSONB
column, enable theenable_full_json
configuration parameter. For more details, refer to JSON Functions.
JSONB data type stores JSON documents in a binary format, making it ideal for handling semi-structured and hierarchical data.
JSONB is significantly faster to process than JSON because it eliminates the need for JSON string parsing during each function execution. During insertion, JSON documents are validated and canonicalized-whitespace is removed, and member keys are sorted. Note that duplicate keys are not permitted.
Example
Create a table my_table
with a column jsonb_data
of data type JSONB
.
sql
create table jsonbtable (data jsonb);
insert into jsonbtable values ('{"c":3, "b":2, "a":1}');
select * from jsonbtable;
data
---------------
{"a":1,"b":2,"c":3}
(1 row)
Querying JSON Data
JSONB supports efficient retrieval using Json path expression. For more examples, see Querying JSON Data.