books with columns id (integer) and details (JSONB).details column.details contains the key 'author' using the ? operator.details contains the key 'publisher' using the ? operator.books with columns id (integer) and details (JSONB).details column.details contains the key 'author' using the ? operator.details contains the key 'publisher' using the ? operator.books table with JSONB columnbooks with two columns: id as an integer primary key and details as a JSONB type.Use CREATE TABLE with id INTEGER PRIMARY KEY and details JSONB.
booksbooks table with these exact values: (1, '{"author": "Alice", "genre": "Fiction"}'), (2, '{"author": "Bob", "year": 2020}'), and (3, '{"genre": "Non-fiction", "publisher": "XYZ Press"}').Use INSERT INTO books (id, details) VALUES with the exact JSONB strings.
'author'books where the details JSONB column contains the key 'author' using the ? operator.Use SELECT * FROM books WHERE details ? 'author' to find rows with the key.
'publisher'books where the details JSONB column contains the key 'publisher' using the ? operator.Use SELECT * FROM books WHERE details ? 'publisher' to find rows with the key.
What does the PostgreSQL JSONB existence operator ? check for?
? operator checks for the presence of a key or string in JSONB data.Which of the following is the correct syntax to check if the key 'name' exists in a JSONB column data?
SELECT * FROM users WHERE data ? 'name';
? operator requires the key as a string literal in single quotes.Given the table products with a JSONB column attributes containing {"color": "red", "size": "M"}, what will this query return?
SELECT id FROM products WHERE attributes ? 'color';
attributes ? 'color' checks if the key 'color' exists in the JSONB column.Identify the error in this query that checks if the key "status" exists in the JSONB column info:
SELECT * FROM orders WHERE info ? status;
status without quotes, causing a syntax error or wrong interpretation.You want to find all rows in the events table where the JSONB column details contains either the key 'location' or the key 'venue'. Which query correctly uses the JSONB existence operator to achieve this?
?| operator checks if any key in the array exists in the JSONB data.?| array['location', 'venue'], which matches the requirement.Pass the test and this pattern moves unknown