Complete the code to create a table with a JSON column named 'data'.
CREATE TABLE users (id SERIAL PRIMARY KEY, [1] JSON);The column name should be 'data' as specified. The type JSON allows storing JSON objects.
Complete the code to add a JSONB column named 'attributes' to the existing table 'products'.
ALTER TABLE products ADD COLUMN [1] JSONB;The column to add is named 'attributes' and should be of type JSONB for efficient JSON storage.
Fix the error in the code to create a table with a JSON column named 'profile'.
CREATE TABLE users (id SERIAL PRIMARY KEY, profile [1]);The column 'profile' must be of type JSON to store JSON data. TEXT or VARCHAR would store plain text, not JSON.
Fill both blanks to create a table 'orders' with a JSONB column 'order_info' and a JSON column 'metadata'.
CREATE TABLE orders (id SERIAL PRIMARY KEY, order_info [1], metadata [2]);
'order_info' should be JSONB for efficient JSON storage and indexing, while 'metadata' is JSON type.
Fill all three blanks to create a table 'events' with columns: 'id' as primary key, 'event_data' as JSONB, and 'extra_info' as JSON.
CREATE TABLE events (id [1] PRIMARY KEY, event_data [2], extra_info [3]);
'id' should be SERIAL for auto-increment primary key, 'event_data' as JSONB, and 'extra_info' as JSON.