What does the term ‘aggregate function’ refer to in SQL?
a) A function that performs calculations on a set of values b) A function that counts unique values c) A function that retrieves data from multiple tables d) A function that updates records
Correct Answer: a) A function that performs calculations on a set of values
Explanation: Aggregate functions perform calculations on a set of values and return a single summary value, such as SUM(), AVG(), COUNT(), etc.
Question 42
Which SQL keyword is used to specify the conditions for a query after grouping has occurred?
a) WHERE b) HAVING c) GROUP BY d) ORDER BY
Correct Answer: b) HAVING
Explanation: The HAVING clause is used to filter groups of records after the aggregation has been performed.
Question 43
Which SQL clause is used to limit the number of rows returned by a query?
a) LIMIT b) TOP c) OFFSET d) ROWS
Correct Answer: a) LIMIT
Explanation: The LIMIT clause restricts the number of rows returned in the result set of a SQL query.
Question 44
Which SQL function would you use to get the current time?
a) NOW() b) CURTIME() c) GETTIME() d) CURRENT_TIME()
Correct Answer: b) CURTIME()
Explanation: The CURTIME() function returns the current time from the system clock in SQL.
Question 45
What does the SQL command ROLLBACK do?
a) Saves all changes made in the current transaction b) Undoes changes made in the current transaction c) Commits changes to the database d) Removes a transaction from the database
Correct Answer: b) Undoes changes made in the current transaction
Explanation: The ROLLBACK command is used to undo any changes made during the current transaction, reverting the database to its previous state.
Question 46
Which SQL statement is used to change a database’s default character set?
a) ALTER DATABASE b) CHANGE DATABASE c) UPDATE DATABASE d) MODIFY DATABASE
Correct Answer: a) ALTER DATABASE
Explanation: The ALTER DATABASE statement is used to modify database properties, including changing the default character set.
Question 47
What is the purpose of a schema in SQL?
a) To define a user’s permissions b) To structure the organization of data c) To store temporary data d) To link tables together
Correct Answer: b) To structure the organization of data
Explanation: A schema defines the organization of data, including how tables and relationships are structured in the database.
Question 48
Which SQL function would you use to find the total number of rows in a specific column?
a) TOTAL() b) COUNT() c) SUM() d) NUMBER()
Correct Answer: b) COUNT()
Explanation: The COUNT() function is used to determine the total number of rows in a specific column, including those that may contain NULL values.
Question 49
Which SQL statement is used to modify an existing column’s data type?
a) ALTER TABLE MODIFY COLUMN b) CHANGE COLUMN TYPE c) UPDATE COLUMN TYPE d) ALTER COLUMN
Correct Answer: a) ALTER TABLE MODIFY COLUMN
Explanation: The ALTER TABLE statement with MODIFY COLUMN is used to change the data type of an existing column in SQL.
Question 50
Which SQL clause is used to combine results from two or more SELECT statements?
a) COMBINE b) UNION c) MERGE d) JOIN
Correct Answer: b) UNION
Explanation: The UNION clause combines the result sets of two or more SELECT statements into a single result set, eliminating duplicates.