Bird
0
0

Given the following SQL commands, what will be the output of the last SELECT?

medium📝 query result Q13 of 15
PostgreSQL - Advanced Features
Given the following SQL commands, what will be the output of the last SELECT?
CREATE EXTENSION IF NOT EXISTS hstore;
SELECT 'a=>1, b=>2'::hstore -> 'a' AS value_a;
ASyntax error
B1
CNULL
D'1'
Step-by-Step Solution
Solution:
  1. Step 1: Understand hstore key-value retrieval

    The operator -> when used with hstore returns the value as type hstore, which is text but includes quotes in output.
  2. Step 2: Analyze the given hstore and query

    The hstore contains keys 'a' and 'b' with values '1' and '2' as text. Selecting -> 'a' returns the value as text with quotes, so output is '1'.
  3. Final Answer:

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

    hstore -> key returns quoted text value [OK]
Quick Trick: hstore -> key returns text value shown quoted [OK]
Common Mistakes:
  • Thinking output is unquoted 1
  • Confusing -> with ->> operator
  • Assuming NULL if key exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes