You are running a query against a relational database. Referring to the scenario above, what clause or command do you use in the query to help avoid a costly tablescan?

  1. GROUP BY clause

  2. INDEX command

  3. HAVING clause

  4. FROM clause

  5. WHERE clause [/quote]


Correct Option: B

AI Explanation

To answer this question, you need to understand how to optimize query performance in a relational database.

The correct answer is B) INDEX command.

The INDEX command is used to create an index on one or more columns of a table, which helps improve query performance by allowing the database to quickly locate the rows that satisfy a certain condition. When an index is created, the database creates a separate data structure that stores the indexed column(s) in a sorted order, making it faster to search for specific values.

The other options are incorrect:

A) GROUP BY clause - The GROUP BY clause is used to group rows that have the same values in specific columns. While it can help organize the data for aggregation functions, it does not directly optimize query performance.

C) HAVING clause - The HAVING clause is used to filter the results of a query based on a condition applied to the grouped data. Similar to the GROUP BY clause, it is used for data manipulation rather than optimization.

D) FROM clause - The FROM clause is used to specify the table(s) from which you want to retrieve data in a query. It does not directly optimize query performance.

E) WHERE clause - The WHERE clause is used to specify the conditions that must be met for a row to be included in the result set. While it can help filter the data, it does not directly optimize query performance.

Therefore, the correct answer is B) INDEX command because it is specifically used to improve query performance by creating an index on one or more columns of a table.

Find more quizzes: