[qsm quiz=29]
Certainly! Here are 20 more SQL questions and answers:
Q: What is the difference between UNION and UNION ALL in SQL?
A: UNION removes duplicate rows from the combined result set, while UNION ALL includes all rows, including duplicates.
Q: What is the purpose of the LIKE operator in SQL?
A: The LIKE operator in SQL is used to search for a specified pattern within a column. It is often used with wildcard characters (% and _).
Q: What is a stored function in SQL?
A: A stored function in SQL is a named set of SQL statements that takes input parameters, performs computations, and returns a single value.
Q: What is the purpose of the COUNT() function in SQL?
A: The COUNT() function in SQL is used to count the number of rows that match a specified condition or column in a table.
Q: What is the purpose of the MAX() function in SQL?
A: The MAX() function in SQL is used to retrieve the maximum value from a specified column in a table.
Q: What is the purpose of the MIN() function in SQL?
A: The MIN() function in SQL is used to retrieve the minimum value from a specified column in a table.
Q: What is a self-join in SQL?
A: A self-join in SQL is a join operation where a table is joined with itself, typically using different table aliases, to create a result set that combines related rows.
Q: What is the purpose of the CASE statement in SQL?
A: The CASE statement in SQL allows you to perform conditional logic and return different values based on specified conditions.
Q: What is the purpose of the EXISTS operator in SQL?
A: The EXISTS operator in SQL is used to check if a subquery returns any rows. It returns true if the subquery has at least one row, and false otherwise.
Q: What is the difference between a primary key and a unique key in SQL?
A: A primary key is used to uniquely identify each row in a table and cannot contain null values. A unique key ensures that the values in a column (or a set of columns) are unique, but it allows null values.
Q: What is the purpose of the TRUNCATE TABLE statement in SQL?
A: The TRUNCATE TABLE statement in SQL is used to remove all rows from a table, effectively resetting the table’s data.
Q: What is the purpose of the ALTER TABLE statement in SQL?
A: The ALTER TABLE statement in SQL is used to modify the structure of an existing table, such as adding or removing columns, modifying column definitions, or changing table constraints.
Q: What is a deadlock in SQL?
A: A deadlock in SQL is a situation where two or more transactions are unable to proceed because each is waiting for a resource that the other transaction holds.
Q: What is a correlated subquery in SQL?
A: A correlated subquery in SQL is a subquery that references columns from the outer query, allowing the subquery to be evaluated for each row of the outer query.
Q: What is the purpose of the ROLLBACK statement in SQL?
A: The ROLLBACK statement in SQL is used to undo changes made by a transaction and restore the database to its previous state.
Q: What is the purpose of the COMMIT statement in SQL?
A: The COMMIT statement in SQL is used to save the changes made by a transaction and make them permanent in the database.
Q: What is the purpose of the INDEX in SQL?
A: An INDEX in SQL is a database object that improves the speed of data retrieval operations on a table by creating a sorted copy of selected columns.
Q: What is a clustered index in SQL?
A: A clustered index in SQL determines the physical order of data rows in a table. Each table can have only one clustered index.
Q: What is a non-clustered index in SQL?
A: A non-clustered index in SQL is a separate structure from the data rows and provides a quick lookup mechanism for accessing data based on indexed columns.
Q: What is the purpose of the SET operator in SQL?
A: The SET operator in SQL is used to combine the result sets of two or more SELECT statements into a single result set, including all rows.
