POST_START
Deleting Selected Records from Delta Tables
I recently needed to clean up some customer data in my Delta table. The task was to remove a specific customer record by their ID. I started by checking the current state of the table to make sure I understood what I was working with.
SELECT * FROM training.sales.customers;
I saw a representative result like this:
| customer_id | customer_name | region | status |
|---|---|---|---|
| 1001 | Maria Keller | EU | ACTIVE |
| 1002 | Daniel Smith | US | ACTIVE |
| 1003 | Sofia Rossi | EU | INACTIVE |
I noticed that customer_id 1002 was the one I needed to delete. Before making any changes, I wanted to be absolutely sure I was targeting the correct record. Once I confirmed the details, I proceeded with the deletion operation.
DELETE FROM training.sales.customers WHERE customer_id = 2;
I saw a representative result like this:
Command completed; matching rows were deleted.
After running the delete command, I wanted to verify that the record was actually removed. I ran a select query again to check the updated state of the table.
SELECT * FROM training.sales.customers;
I saw a representative result like this:
| customer_id | customer_name | region | status |
|---|---|---|---|
| 1001 | Maria Keller | EU | ACTIVE |
| 1003 | Sofia Rossi | EU | INACTIVE |
I verified that the customer with ID 2 was no longer present in the table. This confirmed that the deletion was successful. It was a straightforward operation, but it’s always important to double-check the results to avoid accidental data loss.


Leave a Reply