0
0
PostgreSQLquery~5 mins

JSONB existence (?) operator in PostgreSQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A#>
B@>
C->
D?
What does the query SELECT * FROM users WHERE info ? 'email'; return?
ARows where 'email' key exists in 'info' JSONB column
BRows where 'email' key does not exist
CRows where 'email' value equals true
DRows where 'info' is null
Can the JSONB existence (?) operator check for nested keys inside JSON objects?
AYes, it checks all nested keys
BNo, only top-level keys
COnly if keys are arrays
DOnly if keys are strings
What type of value does the JSONB existence (?) operator return?
ABoolean
BString
CInteger
DJSONB
Which operator would you use to check if a JSONB column contains a specific JSON structure?
A?
B->
C@>
D#>
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.