In a Non-Clustered Index, the emp_name values are stored in a sorted order, and each entry in the index points to the corresponding row in the table (using the emp_id as the reference).
So, the Non-Clustered Index on emp_name will maintain the order of employee names (sorted alphabetically, in this case) and include a pointer to the actual data row (which includes the emp_id, emp_age, and other details).
Thus, when you search by emp_name, the database uses the index to quickly find the corresponding emp_id (and other data), without having to scan the entire table.
Here's a recap:
The Non-Clustered Index sorts the emp_name values.
Each sorted emp_name in the index has a pointer to the actual row in the table that contains the full employee data.
The data in the table itself is not sorted by emp_name but can be efficiently accessed using the index.
So yes, your understanding is correct!
Top comments (0)