Bird
0
0

Why does the operator #> '{a,b}' return JSON, while #>> '{a,b}' returns text in PostgreSQL?

hard📝 Conceptual Q10 of 15
PostgreSQL - JSON and JSONB
Why does the operator #> '{a,b}' return JSON, while #>> '{a,b}' returns text in PostgreSQL?
ABoth return JSON but in different formats
B#> returns text; #>> returns JSON
C#> returns JSON value at path; #>> returns text by converting JSON to string
DBoth return text but #> includes quotes
Step-by-Step Solution
Solution:
  1. Step 1: Understand #> operator

    #> extracts JSON value at the specified path without converting it.
  2. Step 2: Understand #>> operator

    #>> extracts the value and converts it to text (string), removing JSON formatting.
  3. Final Answer:

    #> returns JSON value at path; #>> returns text by converting JSON to string -> Option C
  4. Quick Check:

    #> = JSON, #>> = text conversion [OK]
Quick Trick: Remember: #> = JSON, #>> = text conversion [OK]
Common Mistakes:
  • Confusing which operator returns JSON or text
  • Assuming both return same type
  • Thinking #>> returns JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes