#1
Which keyword is used to create a view in SQL?
CREATE VIEW
ExplanationDefines a virtual table based on the result of a SELECT statement.
#2
What is the primary purpose of SQL query optimization?
To minimize the query execution time
ExplanationEnhances query performance by reducing resource consumption and execution time.
#3
Which SQL function is used to find the maximum value in a column?
MAX()
ExplanationReturns the maximum value in a specified column.
#4
What is the purpose of a SQL index?
To improve the performance of queries
ExplanationSpeeds up data retrieval by providing quick access to rows in a table.
#5
Which SQL statement is used to update data in a database?
UPDATE
ExplanationModifies existing data in a table based on specified conditions.
#6
Which SQL command is used to add a new row to a table?
INSERT INTO
ExplanationAdds new records into a table.
#7
Which SQL function is used to count the number of rows in a result set?
COUNT()
ExplanationReturns the number of rows that match the specified condition.
#8
Which SQL statement is used to delete data from a database?
DELETE
ExplanationRemoves rows from a table based on specified criteria.
#9
Which SQL function is used to return the current date and time?
CURRENT_TIMESTAMP()
ExplanationReturns the current date and time.
#10
Which SQL keyword is used to retrieve unique rows from a query result?
DISTINCT
ExplanationFilters duplicate rows from the result set.
#11
Which SQL keyword is used to specify the order of the result set?
ORDER BY
ExplanationSorts the result set based on specified column(s) in ascending or descending order.
#12
In SQL, which type of join returns all rows from both tables, joining records where available?
OUTER JOIN
ExplanationRetrieves matching records and includes non-matching rows from both tables.
#13
What is a correlated subquery in SQL?
A subquery that uses values from the outer query
ExplanationExecutes a subquery for each row processed by the outer query.
#14
Which index type in SQL can speed up SELECT queries but may slow down data modification operations?
Non-clustered index
ExplanationImproves read performance by storing index keys separate from the actual data.
#15
What does ACID stand for in the context of database transactions?
Atomicity, Consistency, Isolation, Durability
ExplanationDefines properties ensuring reliable and consistent transaction processing.
#16
Which SQL command is used to remove a table from the database?
DROP TABLE
ExplanationDeletes an existing table and its data from the database.
#17
What is the purpose of the GROUP BY clause in SQL?
To group rows with the same values into summary rows
ExplanationGroups rows that have the same values into summary rows.
#18
What is a common use case for using a SQL subquery?
To filter results based on a condition
ExplanationUses a query nested within another query to filter results.
#19
What is the purpose of the EXPLAIN keyword in SQL?
To show the execution plan of a query
ExplanationProvides insights into how a query will be executed by the database engine.
#20
What is a self join in SQL?
A join operation within the same table
ExplanationJoins a table with itself.
#21
Which SQL clause is used to limit the number of rows returned by a query?
LIMIT
ExplanationRestricts the number of rows returned in the result set.
#22
What is SQL injection?
A technique to manipulate a database by injecting malicious SQL code
ExplanationExploits vulnerabilities by injecting malicious SQL code to gain unauthorized access.
#23
In SQL, what is the purpose of the HAVING clause?
To specify conditions on groups
ExplanationFilters groups based on specified conditions after the GROUP BY clause.
#24
What is a scalar subquery in SQL?
A subquery that returns a single value
ExplanationReturns a single value as a result.
#25
What is a derived table in SQL?
A table created temporarily within the scope of a query
ExplanationExists only for the duration of the query execution.