Posts

Showing posts with the label jsonb

Using JSONB in PostgreSQL

Image
Introduction JSONB , short for JSON Binary , is a data type developed from the JSON data type and supported by PostgreSQL since version 9.2. The key difference between JSON and JSONB lies in how they are stored. JSONB supports binary storage and resolves the limitations of the JSON data type by optimizing the insert process and supporting indexing. If you want to know how to install PostgreSQL and learn some basic knowledge about it, check out this article . Defining a Column The query below will create a table with a column of the JSONB data type, which is very simple: CREATE TABLE table_name ( id int , name text , info jsonb ); Inserting Data To insert data into a table with a JSONB column, enclose the content within single quotes ('') like this: INSERT INTO table_name VALUES ( 1 , 'name' , '{"text": "text value", "boolean_vaule": true, "array_value": [1, 2, 3]}' ); We can also insert into an array of o