OA Exams

  • web.groovymark@gmail.com
  • December 10, 2024

Question 41

Which SQL clause is used to retrieve a specific number of rows from the result set?

a) LIMIT
b) SELECT
c) ORDER BY
d) GROUP BY

Correct Answer: a) LIMIT

Explanation: The LIMIT clause is used to specify the number of rows to return from the result set. SELECT retrieves data, ORDER BY sorts the result set, and GROUP BY groups rows based on column values.

Question 42

What is the purpose of the INDEX in SQL?

a) To retrieve rows from a table
b) To store data in a table
c) To improve the performance of queries
d) To create a new table

Correct Answer: c) To improve the performance of queries

Explanation: An index in SQL is used to improve the performance of queries by allowing the database to find rows more quickly. It does not store data or create new tables but enhances the efficiency of data retrieval.

Question 43

Which SQL function is used to extract the year from a date?

a) YEAR()
b) DATE()
c) EXTRACT()
d) SUBSTRING()

Correct Answer: a) YEAR()

Explanation: The YEAR() function extracts the year from a date. DATE() is used to format a date, EXTRACT() extracts parts of a date but requires specifying the unit, and SUBSTRING() extracts portions of a string.

Question 44

What type of data structure is typically used for fast data lookup in databases?

a) Linked list
b) Hash table
c) Stack
d) Queue

Correct Answer: b) Hash table

Explanation: A hash table is commonly used for fast data lookup in databases due to its ability to map keys to values efficiently. Linked lists, stacks, and queues are used for different purposes and do not provide the same efficiency for lookups.

Question 45

What is the purpose of the ALTER statement in SQL?

a) To add, modify, or delete columns in an existing table
b) To insert data into a table
c) To remove a table from the database
d) To retrieve data from a table

Correct Answer: a) To add, modify, or delete columns in an existing table

Explanation: The ALTER statement is used to modify the structure of an existing table, including adding, modifying, or deleting columns. INSERT adds data, DROP removes tables, and SELECT retrieves data.

Question 46

In SQL, what is the purpose of the HAVING clause?

a) To filter groups of rows after aggregation
b) To filter rows before aggregation
c) To filter duplicate rows
d) To combine rows from multiple tables

Correct Answer: a) To filter groups of rows after aggregation

Explanation: The HAVING clause is used to filter groups of rows after they have been aggregated, often used with GROUP BY. WHERE is used to filter rows before aggregation, DISTINCT filters duplicates, and JOIN combines rows from multiple tables.

Question 47

Which SQL operator is used to select rows that match a specified pattern?

a) BETWEEN
b) LIKE
c) IN
d) EXISTS

Correct Answer: b) LIKE

Explanation: The LIKE operator is used to select rows that match a specified pattern. BETWEEN selects values within a range, IN checks if a value is in a list, and EXISTS checks if a subquery returns any rows.

Question 48

What is the purpose of the DROP command in SQL?

a) To delete data from a table
b) To remove a table or database
c) To modify the structure of a table
d) To retrieve data from a table

Correct Answer: b) To remove a table or database

Explanation: The DROP command is used to remove a table or database from the system. It completely deletes the structure, unlike DELETE, which removes data but retains the table.

Question 49

Which SQL statement is used to combine the result sets of two or more SELECT statements?

a) JOIN
b) UNION
c) GROUP BY
d) ORDER BY

Correct Answer: b) UNION

Explanation: The UNION statement is used to combine the result sets of two or more SELECT statements, removing duplicates by default. JOIN combines rows from tables, GROUP BY groups rows, and ORDER BY sorts the result set.

Question 50

What is the role of the PRIMARY KEY in a relational database?

a) To allow duplicate rows in a table
b) To uniquely identify each row in a table
c) To create a foreign key relationship
d) To sort the table by a column

Correct Answer: b) To uniquely identify each row in a table

Explanation: The PRIMARY KEY uniquely identifies each row in a table and ensures that no duplicate values exist. It is crucial for maintaining data integrity, while foreign keys link tables, and sorting is handled by ORDER BY.

Complete the Captcha to view next question set.

Tags

Prev Post
WGU D377 Practice Exam Questions – Set 5 – Part 3
Next Post
WGU D286 Practice Exam Questions – Set 1 – Part 2