# Mirror data between tables (without truncate)

**URL:** <https://community.easymorph.com/t/mirror-data-between-tables-without-truncate/2890>\
**Category:** General Q&A\
**Created:** [July 12, 2021, 2:21pm UTC](https://community.easymorph.com/t/mirror-data-between-tables-without-truncate/2890 "2021-07-12T14:21:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jquintard](https://community.easymorph.com/letter_avatar_proxy/v4/letter/j/ce73a5/32.png) [@jquintard](https://community.easymorph.com/u/jquintard)\
**Post date:** [July 12, 2021, 2:21pm UTC](https://community.easymorph.com/t/mirror-data-between-tables-without-truncate/2890/1 "2021-07-12T14:21:27Z")

</div>

Hi there,

I'am looking to mirror records between two databases. The easiest method is to truncate the records in the destination and bulk the data from the source to the destination but this is a bad way, during this actions, users can't use the remote database.

Suppose I have this records :

**LocalTable**  
ID Name  
1 Sophie  
2 Laurent  
3 Aurélien

**RemoteTable**  
ID Name  
1 Sophie  
2 Renaud  
4 Marc

How I can simply :

- Add records from LocalTable with ID not existing in RemoteTable (like ID 3)
- Delete records in RemoteTable where ID not existing in LocalTable (like ID 4)
- Update records where fields where not strictly equals (like ID 2)
- Do nothing with the rest (or just an update like the previous line)

Do you have an example ?

Jerome

---

<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 12, 2021, 5:16pm UTC](https://community.easymorph.com/t/mirror-data-between-tables-without-truncate/2890/2 "2021-07-12T17:16:41Z")

</div>

> [@jquintard](#):
>
> Add records from LocalTable with ID not existing in RemoteTable (like ID 3)

- Pull IDs from the local and remote tables into two tables
- Use the "Keep/remove matching" to obtain the difference
- Use the ["Select matching database rows" action](https://help.easymorph.com/doku.php?id=transformations:selectdbrowsbykeys) to pull only the rows with IDs that are different

> [@jquintard](#):
>
> Delete records in RemoteTable where ID not existing in LocalTable (like ID 4)

The ["Delete matching database rows" action](https://help.easymorph.com/doku.php?id=transformations:deletedbrowsbykeys) does exactly that.

 ![image](https://community.easymorph.com/uploads/default/original/2X/7/7c63cd36e8b30cf5afa0c7877351a0cac83d3b02.png)

> [@jquintard](#):
>
> Update records where fields where not strictly equals (like ID 2)

- Identify rows to update
- Delete them using the "Delete matching DB rows" action and then re-insert with correct data
