Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Advanced SQLEasy
Q1. A view in SQL is:
- A.A stored procedure in the database server
- B.A virtual table based on a SELECT query✓ Correct
- C.A physical copy of a table stored on disk
- D.A type of index on one or more columns
Explanation
A view is a virtual table whose contents are defined by a SELECT query.
Report an error in this question
Advanced SQLEasy
Q2. Which SQL command creates a view?
- A.INSERT VIEW
- B.MAKE VIEW
- C.BUILD VIEW
- D.CREATE VIEW✓ Correct
Explanation
CREATE VIEW is used to create a virtual table based on a query.
Report an error in this question
Advanced SQLEasy
Q3. A stored procedure is:
- A.A precompiled set of SQL statements stored in the database✓ Correct
- B.An index structure built on one or more columns of a table
- C.A type of view that shows data from multiple source tables
- D.A constraint that enforces data integrity rules on a table
Explanation
A stored procedure is a precompiled collection of SQL statements stored and executed on the server.
Report an error in this question
Advanced SQLEasy
Q4. A trigger in SQL is:
- A.A constraint that restricts the values allowed in a specific column
- B.A type of view that displays filtered data from the underlying table
- C.A manual query written by the user and executed on demand each time
- D.A procedure that automatically executes when a specific event occurs✓ Correct
Explanation
A trigger is a special procedure that automatically fires in response to INSERT, UPDATE, or DELETE events.
Report an error in this question
Advanced SQLEasy
Q5. What is a cursor in SQL?
- A.A pointer to a table that references its location in data storage
- B.A database object used to retrieve and process rows one at a time✓ Correct
- C.A type of index structure created on one or more table columns
- D.A constraint on a column that restricts the allowed data values
Explanation
A cursor allows row-by-row processing of query results.
Report an error in this question
Advanced SQLEasy
Q6. Which SQL statement is used to grant privileges?
- A.PERMIT
- B.ALLOW
- C.ENABLE
- D.GRANT✓ Correct
Explanation
The GRANT statement assigns specific privileges to users or roles.
Report an error in this question
Advanced SQLEasy
Q7. Which SQL statement removes privileges?
- A.DENY
- B.DISABLE
- C.REVOKE✓ Correct
- D.REMOVE
Explanation
The REVOKE statement removes previously granted privileges from users or roles.
Report an error in this question
Advanced SQLEasy
Q8. An assertion in SQL is:
- A.A view that provides a virtual representation of the underlying data
- B.A stored procedure that runs on a scheduled basis within the server
- C.A constraint that specifies a condition the database must always satisfy✓ Correct
- D.A type of trigger that fires automatically when data changes occur
Explanation
An assertion is a general constraint that the DBMS checks and enforces on the database.
Report an error in this question
Advanced SQLEasy
Q9. What is a transaction in SQL?
- A.A type of view that provides a virtual representation of table data
- B.A single SELECT query that retrieves data from the database tables
- C.An index structure that speeds up data retrieval from large tables
- D.A sequence of operations treated as a single logical unit of work✓ Correct
Explanation
A transaction is a sequence of operations performed as a single logical unit of work.
Report an error in this question
Advanced SQLEasy
Q10. The COMMIT statement in SQL:
- A.Creates a savepoint within the current active transaction
- B.Starts a new transaction and initializes the session state
- C.Undoes all changes made in the current transaction entirely
- D.Saves all changes made in the current transaction permanently✓ Correct
Explanation
COMMIT permanently saves all changes made during the current transaction.
Report an error in this question
Advanced SQLMedium
Q11. A materialized view differs from a regular view in that it:
- A.Cannot be refreshed or updated at all
- B.Physically stores the result set on disk✓ Correct
- C.Is always virtual and never materialized
- D.Does not use SELECT queries for data
Explanation
A materialized view stores the query result physically on disk, unlike a regular view which is virtual.
Report an error in this question
Advanced SQLMedium
Q12. Window functions in SQL are used to:
- A.Delete rows from tables based on specified filtering conditions
- B.Create new tables by defining their schema and column structures
- C.Perform calculations across a set of rows related to the current row✓ Correct
- D.Modify table structure by adding or removing column definitions
Explanation
Window functions perform calculations across a window of rows related to the current row without collapsing them.
Report an error in this question
Advanced SQLMedium
Q13. The ROW_NUMBER() function in SQL:
- A.Deletes duplicate rows from the result set of the current query
- B.Returns the primary key value from the underlying data table
- C.Assigns a unique sequential number to each row within a partition✓ Correct
- D.Counts the total number of rows stored in the entire data table
Explanation
ROW_NUMBER() assigns a unique sequential integer to each row within its partition.
Report an error in this question
Advanced SQLMedium
Q14. A Common Table Expression (CTE) is:
- A.A trigger that fires automatically in response to a data change
- B.A stored procedure that encapsulates reusable database SQL logic
- C.A permanent table that persists after the query has been executed
- D.A temporary named result set used within a single SQL statement✓ Correct
Explanation
A CTE provides a temporary named result set that exists for the scope of a single SQL statement.
Report an error in this question
Advanced SQLMedium
Q15. The RANK() function differs from ROW_NUMBER() in that:
- A.RANK() never produces ties in the ranking of any result set rows
- B.RANK() assigns the same rank to ties and skips subsequent ranks✓ Correct
- C.ROW_NUMBER() handles ties by assigning them the same rank value
- D.They are identical and produce exactly the same results always
Explanation
RANK() gives the same rank to tied rows and skips the next rank(s), while ROW_NUMBER() always gives unique numbers.
Report an error in this question
Advanced SQLMedium
Q16. A recursive CTE is used for:
- A.Querying hierarchical or recursive data structures✓ Correct
- B.Creating indexes on one or more table columns
- C.Optimizing joins between tables in the query
- D.Dropping tables from the database permanently
Explanation
Recursive CTEs are used to query hierarchical data like organizational charts or tree structures.
Report an error in this question
Advanced SQLMedium
Q17. The SAVEPOINT statement in SQL:
- A.Commits the transaction and makes all changes fully permanent
- B.Starts a new transaction and initializes all session variables
- C.Creates a point within a transaction to which you can roll back✓ Correct
- D.Drops a table and removes it permanently from the data schema
Explanation
SAVEPOINT creates a named point in a transaction to enable partial rollback.
Report an error in this question
Advanced SQLMedium
Q18. An INSTEAD OF trigger:
- A.Executes after the triggering action ends
- B.Never executes regardless of the trigger
- C.Executes before the triggering action runs
- D.Executes in place of the triggering action✓ Correct
Explanation
An INSTEAD OF trigger fires instead of the triggering DML action, often used with views.
Report an error in this question
Advanced SQLMedium
Q19. The MERGE statement in SQL combines:
- A.Only DDL operations such as CREATE, ALTER, and DROP tables
- B.Only INSERT and DELETE operations without any UPDATE logic
- C.Only SELECT operations for querying data from source tables
- D.INSERT, UPDATE, and DELETE operations based on a condition✓ Correct
Explanation
MERGE performs INSERT, UPDATE, or DELETE operations in a single statement based on matching conditions.
Report an error in this question
Advanced SQLMedium
Q20. What is a sequence in SQL?
- A.A type of trigger that fires on data modification
- B.An object that generates sequential numeric values✓ Correct
- C.An ordered view of data filtered by a set condition
- D.A sorted table arranged by a specific column value
Explanation
A sequence is a database object that generates a series of unique numeric values.
Report an error in this question
Advanced SQLHard
Q21. The DENSE_RANK() function differs from RANK() in that:
- A.They are identical in their ranking behavior
- B.DENSE_RANK() only works with string values
- C.DENSE_RANK() skips ranks after ties occur
- D.DENSE_RANK() does not skip ranks after ties✓ Correct
Explanation
DENSE_RANK() assigns consecutive ranks without gaps, unlike RANK() which skips ranks after ties.
Report an error in this question
Advanced SQLHard
Q22. Lateral joins (LATERAL keyword) allow:
- A.The right side of the join to reference columns from the left side✓ Correct
- B.Only cross joins to be performed without any join filter condition
- C.Joining tables without specifying any condition between the rows
- D.Only inner joins to be used between the two tables in the query
Explanation
LATERAL joins allow the subquery on the right to reference columns from the left side of the join.
Report an error in this question
Advanced SQLHard
Q23. The PARTITION BY clause in window functions:
- A.Creates new tables from partitioned subsets of the original data
- B.Divides the result set into partitions for function calculation✓ Correct
- C.Deletes rows from specific partitions based on filter conditions
- D.Physically partitions a table into separate storage file segments
Explanation
PARTITION BY divides rows into groups (partitions) within which the window function is applied.
Report an error in this question
Advanced SQLHard
Q24. Dynamic SQL refers to:
- A.SQL without variables or parameters of any kind
- B.SQL statements constructed and executed at runtime✓ Correct
- C.SQL that runs only during the compilation phase
- D.Static predefined queries that never change at all
Explanation
Dynamic SQL involves constructing and executing SQL statements programmatically at runtime.
Report an error in this question
Advanced SQLHard
Q25. The PIVOT operation in SQL:
- A.Joins two tables together
- B.Transforms rows into columns✓ Correct
- C.Transforms columns into rows
- D.Creates an index on data
Explanation
PIVOT rotates row values into column headers, transforming data from row-oriented to column-oriented format.
Report an error in this question
Advanced SQLHard
Q26. SQL injection can be prevented by:
- A.Using parameterized queries and prepared statements✓ Correct
- B.Storing user passwords in plain text in database
- C.Disabling authentication on the database server
- D.Using dynamic SQL without any input validation
Explanation
Parameterized queries / prepared statements prevent SQL injection by separating SQL code from data.
Report an error in this question
Advanced SQLHard
Q27. A user-defined function (UDF) in SQL differs from a stored procedure in that:
- A.A UDF must return a value and can be used in SELECT statements✓ Correct
- B.A stored procedure can be used directly within SELECT queries
- C.A UDF cannot return any values to the calling SQL statement
- D.They are identical in every way with no functional difference
Explanation
UDFs must return a value and can be used in SQL expressions, while stored procedures may or may not return values.
Report an error in this question
Advanced SQLHard
Q28. The GROUPING SETS clause in SQL:
- A.Groups all rows into one single group regardless of the criteria
- B.Removes grouping and returns individual rows from the result set
- C.Allows specifying multiple grouping combinations in a single query✓ Correct
- D.Sorts the result set based on the specified column or expression
Explanation
GROUPING SETS allows specifying multiple GROUP BY groupings in one query, equivalent to UNION of multiple GROUP BYs.
Report an error in this question
Advanced SQLHard
Q29. ROLLUP and CUBE in SQL GROUP BY are used for:
- A.Generating subtotals and grand totals across multiple dimensions✓ Correct
- B.Sorting data within each group by a specified column expression
- C.Creating indexes on columns that are used in GROUP BY clauses
- D.Deleting grouped data from the tables based on aggregate values
Explanation
ROLLUP generates hierarchical subtotals; CUBE generates subtotals for all combinations of dimensions.
Report an error in this question
Advanced SQLHard
Q30. Temporal tables in SQL track:
- A.Network latency and response metrics
- B.Only the current state of stored data
- C.Deleted tables and their old schemas
- D.Historical changes to data over time✓ Correct
Explanation
Temporal tables automatically track and store the history of data changes over time.
Report an error in this question