AdvancedBasic SELECT

JSONB Data Type

The query

SQL
CREATE TABLE user_preferences (
  user_id INT PRIMARY KEY,
  settings JSONB
);

INSERT INTO user_preferences (user_id, settings)
VALUES (1, '{"theme": "dark", "notifications": {"email": true, "sms": false}}');
Tested against PostgreSQL 16

Note

JSONB stores JSON data in a decomposed binary format. It is much faster to process than standard JSON and supports indexing.