Introduction
We use JSON data to store flexible information in a single column. It helps when data has different shapes or details that change often.
INSERT INTO table_name (json_column) VALUES ('{"key": "value"}');
INSERT INTO users (info) VALUES ('{"name": "Alice", "age": 30}');
INSERT INTO products (details) VALUES ('{"id": 101, "colors": ["red", "blue"]}');
INSERT INTO logs (event) VALUES ('{"type": "login", "success": true}');
CREATE TABLE employees (id SERIAL PRIMARY KEY, data JSON); INSERT INTO employees (data) VALUES ('{"name": "John", "department": "Sales", "full_time": true}'); SELECT * FROM employees;
json column named data?users with a jsonb column info?jsonb '...' .products with a json column details, what will be the result of this query?INSERT INTO products (details) VALUES ('{"color": "red", "size": "M"}');
SELECT details->>'color' FROM products WHERE details->>'size' = 'M';INSERT INTO orders (info) VALUES ('{customer: "Alice", total: 50}');events with a jsonb column payload. Which query correctly inserts two JSON objects in one statement?Pass the test and this pattern moves unknown