Bird
0
0

Which of the following is the correct syntax to update the key "city" to "Paris" in a JSONB column named info using jsonb_set?

easy📝 Syntax Q3 of 15
PostgreSQL - JSON and JSONB
Which of the following is the correct syntax to update the key "city" to "Paris" in a JSONB column named info using jsonb_set?
Ajsonb_set(info, '{city}', '"Paris"')
Bjsonb_set(info, 'city', 'Paris')
Cjsonb_set(info, '{city}', 'Paris')
Djsonb_set(info, 'city', '"Paris"')
Step-by-Step Solution
Solution:
  1. Step 1: Understand jsonb_set syntax

    The second argument is a text array path, so '{city}' is correct. The new value must be a JSON string, so '"Paris"' is needed.
  2. Step 2: Check each option

    jsonb_set(info, '{city}', '"Paris"') uses correct path and properly quoted JSON string. Others either miss braces or quotes.
  3. Final Answer:

    jsonb_set(info, '{city}', '"Paris"') -> Option A
  4. Quick Check:

    Correct syntax = jsonb_set(info, '{key}', '"value"') [OK]
Quick Trick: Use braces for path and double quotes inside single quotes for value [OK]
Common Mistakes:
  • Missing braces around path
  • Not quoting JSON string value
  • Using plain text instead of JSON string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes