Bird
0
0

You wrote this query but get an error:

medium📝 Debug Q6 of 15
PostgreSQL - Advanced Features
You wrote this query but get an error:
SELECT * FROM my_table WHERE data @> '{"key": "value"}';
What is the most likely cause?
AThe @> operator is invalid syntax
BThe table my_table does not exist
CThe JSON string is malformed
DThe data column is not of JSONB type
Step-by-Step Solution
Solution:
  1. Step 1: Understand the @> operator

    @> is the JSONB containment operator, valid only on JSONB columns.
  2. Step 2: Check data column type

    If data is JSON (not JSONB), @> operator causes an error.
  3. Final Answer:

    The data column is not of JSONB type -> Option D
  4. Quick Check:

    @> requires JSONB column type [OK]
Quick Trick: Use JSONB type for @> containment operator [OK]
Common Mistakes:
  • Assuming @> works on JSON type
  • Thinking @> is invalid syntax
  • Ignoring column data type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes