Complete the code to show how an index helps find data faster.
SELECT * FROM employees WHERE employee_id = [1];The employee_id is typically numeric, so use the numeric literal without quotes to match the column type properly and utilize the index.
Complete the code to create an index on the 'name' column.
CREATE INDEX idx_name ON employees([1]);Creating an index on the 'name' column speeds up searches by that column.
Fix the error in the query that tries to use an index.
SELECT * FROM employees WHERE [1] = 'John';
The column name is case-sensitive in some databases; 'name' is correct, 'Name' may cause error.
Fill both blanks to create a query that uses an index to find employees with salary greater than 50000.
SELECT * FROM employees WHERE [1] [2] 50000;
The query filters employees where salary is greater than 50000, using the 'salary' column and the '>' operator. An index on salary enables faster range scans.
Fill all three blanks to create a dictionary comprehension that maps employee names to their salaries, but only for salaries above 60000.
{ [3]['[1]']: [3]['[2]'] for [3] in employees if [3]['[2]'] > 60000 }This comprehension creates a dictionary with employee names as keys and salaries as values, filtering for salaries above 60000.