# Updating a database table

**URL:** <https://community.easymorph.com/t/updating-a-database-table/304>\
**Category:** General Q&A\
**Created:** [October 20, 2017, 3:57am UTC](https://community.easymorph.com/t/updating-a-database-table/304 "2017-10-20T03:57:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmills313](https://community.easymorph.com/letter_avatar_proxy/v4/letter/b/8dc957/32.png) [@bmills313](https://community.easymorph.com/u/bmills313)\
**Post date:** [October 20, 2017, 3:57am UTC](https://community.easymorph.com/t/updating-a-database-table/304/1 "2017-10-20T03:57:55Z")

</div>

I'm wondering if it is possible to update tables in a database using a transformation. My co-workers rely heavily on Excel and I have them copy data into spreadsheets and use various transformations to insert the data in the database and it works great.

Now, I need them to take care of updating data here and there (like the status of an administration or date something closed) and right now they maintain that locally in a spreadsheet which I then manually change in the database. if I could create a project that could accomplish this, that would be perfect. Still really new to this ETL / database stuff so I'm learning as I go 🙂 Any suggestions would be great.

Thanks.

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [October 20, 2017, 4:19am UTC](https://community.easymorph.com/t/updating-a-database-table/304/2 "2017-10-20T04:19:45Z")

</div>

Updating database tables is done in 4 steps:

1. Import necessary rows into [EasyMorph](https://easymorph.com/) using either the "Import from database" transformation (using a query) or "Select DB rows" (using a list of IDs). See the Advanced Topics in this tutorial article: [EasyMorph | Loading data from a database](http://easymorph.com/learn/load-database.html).

2. Modify the rows as necessary in EasyMorph (e.g. update the close date).

3. Delete the rows in the database using either Delete DB Rows (using a query) or Delete matching DB Rows (using a list of IDs). See the Advanced Topics in this article: [EasyMorph | Exporting data into a database](http://easymorph.com/learn/export-database.html))

4. Export modified rows into the target table using the "Export to database" transformation.

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [April 15, 2019, 8:28pm UTC](https://community.easymorph.com/t/updating-a-database-table/304/3 "2019-04-15T20:28:21Z")

</div>

To make it a bit more fail-proof, you can use two more steps:

Add a new step after step 1 above:  
1a. Save the rows into a temporary .dset file using the "Export dataset" action.

Add a new step after step 4 above:  
4a. Delete the temporary file using the "File command" action.

Saving the original data into a temporary file ensures that it isn't lost in case for some reason database rows have been deleted in step 3, but the modified data failed to export in step 4. In case it happened, you can export the saved data from the temporary file back into the database after the cause of failure is fixed.

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [July 6, 2020, 8:02am UTC](https://community.easymorph.com/t/updating-a-database-table/304/4 "2020-07-06T08:02:12Z")

</div>

We've made updating a database table as simple as 1 action with the new "Update DB table" action. Read more here:

> [@bulb Announcement: the "Update database table" action](https://community.easymorph.com/t/annoucement-the-update-database-table-action/1964):
>
> In v4.4 we've added the "Update database table" action that simplifies updating data in database tables with values from EasyMorph. Instead of 5 actions required previously, you can now update DB tables using just 1 action. Here is an illustration how it works: Data before: [image] The goal is to replace "M" with "Married" and "S" with "Single" in the [MaritalStatus] field. Here is an according "Update database table" action: [image] The result: [image] Under the hood, the action generat…
