Complete the code to create an index on the 'name' column of the 'employees' table.
CREATE INDEX [1] ON employees(name);The index name can be any valid identifier. Here, idx_name is a simple and clear name for the index on the 'name' column.
Complete the query to select all rows where the 'age' is greater than 30, using the index on 'age' to speed up the search.
SELECT * FROM employees WHERE age [1] 30;
The query selects employees older than 30, so the operator should be >.
Fix the error in the query to use the index on 'department' to find employees in the 'Sales' department.
SELECT * FROM employees WHERE department [1] 'Sales';
To find exact matches in the 'department' column, use the = operator. This allows the index to be used efficiently.
Fill both blanks to create a query that uses an index to find employees with salary {{BLANK_1}} 50000 and order the results by salary {{BLANK_2}}.
SELECT * FROM employees WHERE salary [1] 50000 ORDER BY salary [2];
The query finds employees with salary greater than 50000 and orders them from highest to lowest salary, so the blanks are filled with > and DESC.
Fill all three blanks to create a query that uses an index to find employees with experience {{BLANK_1}} 5, selects their {{BLANK_2}}, and orders by {{BLANK_3}} ascending.
SELECT [2] FROM employees WHERE experience [1] 5 ORDER BY [3] ASC;
The query selects employees with experience greater or equal to 5, selects their names, and orders by experience ascending. So the blanks are >=, name, and experience.