SQL Server Questions and Answers – Indexing Strategies – 2

This set of SQL Server Questions & Answers for entrance exams focuses on “Indexing Strategies – 2”.

1. Which of the following query is used to enable a disabled index using CREATE INDEX?
a)

CREATE INDEX IX_Employee_OrganizationLevel_OrganizationNode ON HumanResources.Employee
   (OrganizationLevel, OrganizationNode)
WITH (DROP_EXIST = ON);

b)

CREATE INDEX IX_Employee_OrganizationLevel_OrganizationNode ON HumanResources.Employee
   (OrganizationLevel, OrganizationNode)
WITH (DROP_EXISTING = OFF);

c)

advertisement
advertisement
CREATE INDEX IX_Employee_OrganizationLevel_OrganizationNode ON HumanResources.Employee
   (OrganizationLevel, OrganizationNode)
WITH (DROP_EXISTING = ON);

d) None of the mentioned
View Answer

Answer: c
Explanation: Enabling a disabled index can be done using SSMS.

2. Point out the correct statement.
a) When SORT_IN_TEMPDB is set to OFF, the default, the sort runs are stored in the source filegroup
b) The Database Engine first scans the data pages of the base table to retrieve key values and builds an index leaf row for each data row
c) When SORT_IN_TEMPDB is set to ON, the default, the sort runs are stored in the destination filegroup
d) None of the mentioned
View Answer

Answer: b
Explanation: When the internal sort buffers have been filled with leaf index entries, the entries are shorted and written to disk as an intermediate sort run.

advertisement

3. Which of the following query enables the IX_Employee_OrganizationLevel_OrganizationNode index on the Employee table?
a) DBCC DBREINDEX (“Employee”, IX_Employee_OrganizationLevel_OrganizationNode);
b) DBCC REINDEX (“Employee”, IX_Employee_OrganizationLevel_OrganizationNode);
c) DBCC DBINDEX (“Employee”, IX_Employee_OrganizationLevel_OrganizationNode);
d) All of the mentioned
View Answer

Answer: a
Explanation: DBCC DBREINDEX rebuilds one or more indexes for a table in the specified database.

4. Which of the following query can enable all indexes on Employee table?
a) DBCC DBREINDEX (“Employee”, ” “);
b) DBCC DBREINDEX (“EMP”, ” “);
c) DBCC DBREINDEX (“HumanResources.Employee”, “ALL”);
d) None of the mentioned
View Answer

Answer: a
Explanation: DBCC DBREINDEX can enable all indexes for a table in the specified database.

advertisement

5. Point out the wrong statement.
a) If SORT_IN_TEMPDB is set to OFF, the free space in the destination filegroup must be large enough to store the final index structure
b) When you create a clustered index on a table that has nonclustered indexes, you must have available as free space
c) When you set the SORT_IN_TEMPDB option to ON, you must have sufficient free disk space available in master database
d) All of the mentioned
View Answer

Answer: a
Explanation: tempdb is used to store the sort runs, and sufficient free space in the destination filegroup to store the final index structure.

6. Which of the following query disables all the indexes on Employee table?
a) ALTER INDEX MUL ON HumanResources.Employee
DISABLE;
b) ALTER INDEX NEST ON HumanResources.Employee
DISABLE;
c) ALTER INDEX ALL ON HumanResources.Employee
ENABLE;
d) ALTER INDEX ALL ON HumanResources.Employee
DISABLE;
View Answer

Answer: d
Explanation: ALTER statement is used to enable or disable the index.

7. Which of the following index operations require no additional disk space?
a) ALTER INDEX
b) DROP INDEX
c) CREATE INDEX
d) All of the mentioned
View Answer

Answer: d
Explanation: DROP INDEX does not require space when you are dropping a clustered index offline without specifying the MOVE TO clause and nonclustered indexes do not exist.

8. Which of the following index operation require additional disk space?
a) UPDATE INDEX
b) DROP INDEX MOVE TO
c) ALTER INDEX ADD CONSTRAINT
d) All of the mentioned
View Answer

Answer: b
Explanation: DROP INDEX MOVE TO applies only to clustered indexes.

9. The SORT_IN_TEMPDB option cannot be set for ________ statements.
a) ALTER INDEX
b) DROP INDEX
c) CREATE INDEX
d) All of the mentioned
View Answer

Answer: b
Explanation: The temporary mapping index is always created in the same filegroup or partition scheme as the target index.

10. Which of the following query will disable the index on Employee table?
a) ALTER INDEX IX_Employee_OrganizationLevel_OrganizationNode Employee
DISABLE;
b) ALTER INDEX IX_Employee_OrganizationLevel_OrganizationNode ON HumanResources
DISABLE;
c) CREATE INDEX IX_Employee_OrganizationLevel_OrganizationNode ON HumanResources.Employee
DISABLE;
d) None of the mentioned
View Answer

Answer: a
Explanation: DISABLE command is used to disable the index on Employee table.

Sanfoundry Global Education & Learning Series – SQL Server.

To practice all areas of SQL Server for entrance exams, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.