Complete the code to insert a JSON object into the table.
INSERT INTO products (data) VALUES ('[1]');
The JSON object must be a valid JSON string. Option D is correctly formatted JSON.
Complete the code to insert JSON data using the jsonb type.
INSERT INTO orders (order_info) VALUES ([1]);To insert JSONB data, the string must be cast to jsonb type. Option C correctly casts the JSON string.
Fix the error in the INSERT statement for JSON data.
INSERT INTO users (profile) VALUES ('[1]'::json);
The JSON string must be enclosed in single quotes outside and use double quotes inside. Option A is correct because it is a valid JSON string literal.
Fill both blanks to insert JSON data with a nested object.
INSERT INTO events (details) VALUES ('[1]'::[2]);
The JSON string must be valid with double quotes. Casting to jsonb is preferred for better performance.
Fill all three blanks to insert JSON data with an array and cast it properly.
INSERT INTO catalog (info) VALUES ('[1]'::[2]); -- array has [3] items
The JSON string must have double quotes around strings in the array. Casting to jsonb is correct. The array has 3 items.