Hanna Shingare
Posted Answers
Answer
1. Clustered Index : Clustered index is created only when both the following conditions satisfy –
Whenever you apply clustered indexing in a table, it will perform sorting in that table only. You can create only one clustered index in a table like primary key. Clustered index is as same as dictionary where the data is arranged by alphabetical order.
In clustered index, index contains pointer to block but not direct data.
Example of Clustered Index – If you apply primary key to any column, then automatically it will become clustered index.
In this example, Roll no is a primary key, it will automatically act as a clustered index. The output of this code will produce in increasing order of roll no.
You can have only one clustered index in one table, but you can have one clustered index on multiple columns, and that type of index is called composite index.
2. Non-clustered Index : Non-Clustered Index is similar to the index of a book. The index of a book consists of a chapter name and page number, if you want to read any topic or chapter then you can directly go to that page by using index of that book. No need to go through each and every page of a book.
The data is stored in one place, and index is stored in another place. Since, the data and non-clustered index is stored separately, then you can have multiple non-clustered index in a table.
In non-clustered index, index contains the pointer to data.
Example of Non-clustered Index –
Here, roll no is a primary key, hence there is automatically a clustered index. If we want to apply non-clustered index in NAME column (in ascending order), then the new table will be created for that column.
Output before applying non-clustered index :
Output after applying non-clustered index :
Row address is used because, if someone wants to search the data for sudhir, then by using the row address he/she will directly go to that row address and can fetch the data directly.
Difference between Clustered and Non-clustered index :
Answer is posted for the following question.
Answer
Top Augusta Wineries & Vineyards: See reviews and photos of Wineries & Vineyards in Augusta, Missouri on Tripadvisor
Answer is posted for the following question.
What is the best wineries in augusta mo?
Answer
- Quality Insurance Co.
- Divine Policy.
- Life Long & Prosper.
- My Life and Kid.
- Can Rest Insured.
Answer is posted for the following question.
How to name a life insurance company?