Recall & Review
beginner
What does the JSONB existence (?) operator check in PostgreSQL?
It checks if a specified key exists in a JSONB column.
Click to reveal answer
beginner
How do you use the JSONB existence operator to check if the key 'name' exists in a JSONB column called 'data'?
Use the query:
SELECT * FROM table WHERE data ? 'name';Click to reveal answer
beginner
What type of value does the JSONB existence (?) operator return?
It returns a boolean:
true if the key exists, false if it does not.Click to reveal answer
intermediate
Can the JSONB existence (?) operator check for keys inside nested JSON objects?
No, it only checks for top-level keys in the JSONB column.
Click to reveal answer
intermediate
What is the difference between the JSONB existence (?) operator and the containment (@>) operator?
The existence (?) operator checks for a single key's presence, while the containment (@>) operator checks if one JSONB contains another JSONB structure.
Click to reveal answer
Which operator checks if a key exists in a JSONB column in PostgreSQL?
✗ Incorrect
The '?' operator checks if a key exists in a JSONB column.
What does the query
SELECT * FROM users WHERE info ? 'email'; return?✗ Incorrect
The '?' operator filters rows where the specified key exists in the JSONB column.
Can the JSONB existence (?) operator check for nested keys inside JSON objects?
✗ Incorrect
The '?' operator only checks for top-level keys in the JSONB data.
What type of value does the JSONB existence (?) operator return?
✗ Incorrect
It returns a boolean indicating if the key exists.
Which operator would you use to check if a JSONB column contains a specific JSON structure?
✗ Incorrect
The '@>' operator checks if one JSONB contains another JSONB structure.
Explain how the JSONB existence (?) operator works and give an example query.
Think about checking if a key is present in a JSON object stored in a column.
You got /3 concepts.
Describe the limitations of the JSONB existence (?) operator regarding nested JSON keys.
Consider how deep the operator looks inside the JSON structure.
You got /3 concepts.