Bird
0
0

What will be the output of this query if data is a jsonb column containing '{"x":10, "y":20}'?

medium📝 query result Q5 of 15
PostgreSQL - JSON and JSONB
What will be the output of this query if data is a jsonb column containing '{"x":10, "y":20}'?
SELECT data->>'x' FROM table_name;
Aerror
B10
Cnull
D'10'
Step-by-Step Solution
Solution:
  1. Step 1: Understand the ->> operator on jsonb

    The operator ->> extracts the JSON value as text.
  2. Step 2: Apply operator to the given data

    Extracting key 'x' returns the number 10 as text, so the output is the string '10'.
  3. Final Answer:

    '10' -> Option D
  4. Quick Check:

    ->> returns text = A [OK]
Quick Trick: ->> extracts JSON value as text string [OK]
Common Mistakes:
  • Expecting numeric 10 instead of string '10'
  • Confusing -> and ->> operators
  • Assuming null if key exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes