[英]How to sync two tables that are not identical?
我有兩個使用相同數據的項目。 但是,此數據保存在2個不同的數據庫中。 這兩個數據庫中的每個數據庫都有一個與另一個數據庫中的對應表幾乎相同的表。
我正在尋找一種同步兩個表的方法。 更簡單地說,如果database_one.table
獲得插入,則需要將同一記錄插入database2.table
。
Table Products
| product_id | name | description | price | vat | flags |
Table Articles
| articleId | name_short | name | price | price_vat | extra_info | flags |
我從未使用過,也不知道如何使用任何數據庫同步方法。 還讓我擔心的是,表並不相同,因此我將需要以某種方式將列相互映射。
例如:
database_one.Products.name -> database_two.articles.name_short
有人可以幫我弄這個嗎?
您可以使用MERGE函數: https : //www.mssqltips.com/sqlservertip/1704/using-merge-in-sql-server-to-insert-update-and-delete-at-the-same-time/
然后創建一個以所需頻率運行的過程,或者如果需要立即運行,則將合並插入觸發器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.