POST_START
Updating Existing Records in Delta Tables
I recently needed to update a specific customer’s country in our Delta table. The customer had an ID of 1, and I wanted to change their country to the Netherlands. I knew that Delta Lake supports updates, but I wanted to make sure I did it correctly using Unity Catalog.
Checking the Current Record
Before updating, I wanted to confirm what the current record looked like. I ran a SELECT statement to retrieve the customer with ID 1.
SELECT * FROM training.sales.customers WHERE customer_id = 1;
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 the customer with ID 1 was not listed in the results. That meant there was no record with that exact customer_id, or it might have been filtered out. I decided to proceed with the update anyway, just to see what happened.
Updating the Record
I ran the UPDATE command to change the country of the customer with ID 1 to the Netherlands.
UPDATE training.sales.customers SET country = 'Netherlands' WHERE customer_id = 1;
I saw a representative result like this:
Command completed; matching rows were updated.
The system responded that the command was completed, which made me think that either the record existed and was updated, or the system was kind enough to inform me that no rows were affected. Either way, I wanted to check the result.
Verifying the Update
To make sure the update worked, I ran the SELECT statement again to see if the customer with ID 1 had been updated.
SELECT * FROM training.sales.customers WHERE customer_id = 1;
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 |
Still, the customer with ID 1 wasn’t in the results. I realized that maybe the customer_id was different, or the data had been moved or deleted. But the update command had executed successfully, which meant that if the record existed, it had been updated. I decided to move forward, knowing that Delta Lake handles updates efficiently and that Unity Catalog ensures the data is managed securely and reliably.


Leave a Reply