Bird
0
0

Which of the following is the correct syntax to create an expression index on the uppercased username column in PostgreSQL?

easy📝 Syntax Q3 of 15
PostgreSQL - Indexing Strategies
Which of the following is the correct syntax to create an expression index on the uppercased username column in PostgreSQL?
ACREATE INDEX idx_upper_username ON users (UPPER(username));
BCREATE INDEX idx_upper_username ON users USING UPPER(username);
CCREATE INDEX idx_upper_username ON users WHERE UPPER(username);
DCREATE INDEX idx_upper_username ON users (username UPPER);
Step-by-Step Solution
Solution:
  1. Step 1: Recall expression index syntax

    The correct syntax uses CREATE INDEX index_name ON table_name (expression); where expression can be a function like UPPER(column).
  2. Step 2: Check each option

    CREATE INDEX idx_upper_username ON users (UPPER(username)); matches the correct syntax. Options A, B, and C use incorrect keywords or order.
  3. Final Answer:

    CREATE INDEX idx_upper_username ON users (UPPER(username)); -> Option A
  4. Quick Check:

    Expression index syntax = CREATE INDEX ON table (expression) [OK]
Quick Trick: Use parentheses around the expression in CREATE INDEX [OK]
Common Mistakes:
  • Using WHERE instead of expression in index definition
  • Misplacing USING keyword
  • Not enclosing expression in parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes