
Answer-first summary for fast verification
Answer: DELETE FROM my_table WHERE age > 25;
## Explanation The correct answer is **C. DELETE FROM my_table WHERE age > 25;** Here's why: 1. **DELETE statement**: The DELETE statement is specifically designed to remove rows from a table based on a condition. The syntax `DELETE FROM table_name WHERE condition` removes rows that match the condition. 2. **Understanding the requirement**: The question asks to "remove the rows where the value in column age is greater than 25". This means we need to delete rows where `age > 25`. 3. **Analyzing other options**: - **A**: `SELECT * FROM my_table WHERE age > 25;` - This only selects/reads the rows but doesn't remove them. - **B**: `UPDATE my_table WHERE age > 25;` - This is invalid syntax (UPDATE requires SET clause) and even if corrected, UPDATE modifies existing rows rather than removing them. - **D**: `UPDATE my_table WHERE age <= 25;` - Similar to B, invalid syntax and UPDATE doesn't remove rows. - **E**: `DELETE FROM my_table WHERE age <= 25;` - This would delete rows where age is 25 or less, which is the opposite of what's requested. 4. **Delta table context**: In Databricks with Delta tables, the DELETE operation is transactional and maintains ACID properties, ensuring data consistency while removing rows. **Key takeaway**: Use `DELETE FROM table_name WHERE condition` to remove specific rows from a Delta table in Databricks.
Author: Keng Suppaseth
Ultimate access to all questions.
No comments yet.
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?
A
SELECT * FROM my_table WHERE age > 25;
B
UPDATE my_table WHERE age > 25;
C
DELETE FROM my_table WHERE age > 25;
D
UPDATE my_table WHERE age <= 25;
E
DELETE FROM my_table WHERE age <= 25;