DATABRICKS-DATA-ENGINEER-ASSOCIATE practice question 5 of 25

Which of the following code blocks will remove the rows where the value in column age is greater than 25 from the existing Delta table my_table and save the updated table?

Full set: 177 questions
Answer options
A: SELECT * FROM my_table WHERE age > 25;
B: UPDATE my_table WHERE age > 25;
C: DELETE FROM my_table WHERE age > 25; Correct answer
D: UPDATE my_table WHERE age <= 25;
E: DELETE FROM my_table WHERE age <= 25;
Correct Answer:
C. DELETE FROM my_table WHERE age > 25;
Explanation

The DELETE FROM statement is the correct Data Manipulation Language (DML) command in SQL to remove rows from a Delta table. The WHERE clause is used to specify the condition for deletion. In this case, WHERE age > 25 correctly filters for the rows that need to be removed. This operation is atomic; it removes the specified rows and commits the change as a new version to the Delta table's transaction log, thus saving the updated table state.

Why Incorrect

A. The SELECT statement only queries and returns data; it does not perform any modification or deletion on the source table.
B. The UPDATE statement is used to modify the values within existing rows, not to remove them. The syntax is also incomplete without a SET clause.
D. The UPDATE statement modifies rows rather than deleting them, and it targets the incorrect set of rows (age <= 25).
E. This DELETE statement uses the incorrect condition (age <= 25), which would remove the rows that should be kept, not the ones specified. ---

References

1. Databricks SQL Language Reference

DELETE FROM: "Removes the rows that match a predicate." The documentation provides the syntax DELETE FROM tablename [WHERE predicate]

which directly matches the correct answer.

Source: Databricks Documentation > SQL reference > Data manipulation language > DELETE FROM.

2. Databricks Delta Lake Guide

"Table deletes

updates

and merges": "You can remove data that matches a predicate from a Delta table using the DELETE operation. DELETE removes the entire row and does not drop columns." This confirms DELETE is the appropriate operation for removing entire rows based on a condition.

Source: Databricks Documentation > Delta Lake > Delta Lake feature guide > Table deletes

updates

and merges.

Scroll to Top