Challenge - 5 Problems
Index Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the effect of this CREATE INDEX statement?
Consider the SQL statement:
What does this statement do?
CREATE INDEX idx_customer_name ON customers (last_name, first_name);
What does this statement do?
Attempts:
2 left
💡 Hint
Think about what an index does in a database.
✗ Incorrect
The CREATE INDEX statement creates a data structure that helps the database find rows faster when searching or sorting by the specified columns. It does not create a new table or delete data.
📝 Syntax
intermediate2:00remaining
Which CREATE INDEX statement is syntactically correct?
Choose the correct syntax to create an index named idx_order_date on the orders table for the order_date column.
Attempts:
2 left
💡 Hint
Remember the order: CREATE INDEX index_name ON table_name (column_name);
✗ Incorrect
The correct syntax requires the index name immediately after CREATE INDEX, then ON, then the table name, and finally the column list in parentheses.
❓ optimization
advanced2:00remaining
Which index will best optimize queries filtering by both city and state?
You have a customers table with columns city and state. You want to speed up queries that filter by both city and state.
Which CREATE INDEX statement is best?
Which CREATE INDEX statement is best?
Attempts:
2 left
💡 Hint
Think about the order of columns in a multi-column index.
✗ Incorrect
An index on (city, state) is best for queries filtering by city and state in that order. It can also be used for queries filtering only by city. The order matters for optimization.
🔧 Debug
advanced2:00remaining
What error does this CREATE INDEX statement produce?
Consider this SQL statement:
What error will it cause?
CREATE INDEX idx_price ON products price;
What error will it cause?
Attempts:
2 left
💡 Hint
Check the syntax for specifying columns in CREATE INDEX.
✗ Incorrect
The column list must be enclosed in parentheses. Omitting them causes a syntax error.
🧠 Conceptual
expert2:00remaining
What is a key limitation of creating too many indexes on a table?
Which of the following is a main drawback of having many indexes on a database table?
Attempts:
2 left
💡 Hint
Think about what happens when data changes in a table with many indexes.
✗ Incorrect
Each time data changes, all indexes must be updated, which slows down write operations. Queries usually become faster, not slower.