Bird
0
0

You tried to create an expression index with:

medium📝 Debug Q14 of 15
PostgreSQL - Indexing Strategies
You tried to create an expression index with:
CREATE INDEX idx_expr ON sales (price * discount);
But PostgreSQL returned a syntax error. What is the problem?
AExpression indexes require double parentheses around the expression
BYou cannot create indexes on expressions involving multiplication
CThe table name is missing
DThe index name is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check expression index syntax

    Expression indexes must have the expression enclosed in double parentheses to be valid.
  2. Step 2: Identify the syntax error cause

    The given statement uses single parentheses, causing a syntax error.
  3. Final Answer:

    Expression indexes require double parentheses around the expression -> Option A
  4. Quick Check:

    Double parentheses fix syntax error [OK]
Quick Trick: Use double parentheses for expressions to avoid syntax errors [OK]
Common Mistakes:
  • Using single parentheses for expressions
  • Thinking multiplication is not allowed
  • Ignoring syntax error details

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes