Consider a table Employees with columns id, name, and department. A single column index is created on the department column.
What will be the output of the following query?
SELECT name FROM Employees WHERE department = 'Sales';
Assume the table has these rows:
id | name | department 1 | Alice | Sales 2 | Bob | HR 3 | Carol | Sales 4 | Dave | IT
SELECT name FROM Employees WHERE department = 'Sales';
Think about which rows match the condition department = 'Sales'.
The query selects names where the department is 'Sales'. Only Alice and Carol belong to Sales.
What is the main purpose of creating a single column index on a database table?
Think about how indexes help when searching data.
A single column index helps the database find rows faster when queries filter or sort by that column.
Which SQL statement correctly creates a single column index named idx_department on the department column of the Employees table?
Remember the order: CREATE INDEX index_name ON table(column);
The correct syntax is CREATE INDEX idx_department ON Employees(department);
Given a large Orders table with millions of rows, which query will benefit most from a single column index on the customer_id column?
Indexes help when filtering by the indexed column.
The query filtering by customer_id uses the index to quickly find matching rows.
Consider a single column index on department in the Employees table. Why does this query not use the index?
SELECT * FROM Employees WHERE UPPER(department) = 'SALES';
Think about how functions on indexed columns affect index use.
Applying a function like UPPER() on the indexed column disables the index usage because the database cannot use the index on transformed values.