久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

合并來自不同數(shù)據(jù)庫的 2 個表

Merge 2 Tables from different Databases(合并來自不同數(shù)據(jù)庫的 2 個表)
本文介紹了合并來自不同數(shù)據(jù)庫的 2 個表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

假設(shè)我想將來自不同數(shù)據(jù)庫的 2 個表合并到一個表中,其中包含來自 2 個表的所有數(shù)據(jù):

結(jié)果看起來像這樣:

結(jié)果表中的條目是不是多余的,因為保時捷和大眾有2個條目?或者我可以只在股票"列中添加值,因為標(biāo)記"列是明確的?

解決方案

  1. 您需要創(chuàng)建到另一個數(shù)據(jù)庫的數(shù)據(jù)庫鏈接這里是如何創(chuàng)建數(shù)據(jù)庫鏈接的示例 http://psoug.org/definition/create_database_link.htm從另一個數(shù)據(jù)庫創(chuàng)建選擇語句后應(yīng)該看起來:select * from tableA@"database_link_name"
  2. 然后您需要使用 MERGE 語句從另一個數(shù)據(jù)庫推送數(shù)據(jù),因此合并語句應(yīng)如下所示.
  3. 您可以在此處閱讀合并語句:https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606

    <前><代碼>合并到 result_table res使用(選擇標(biāo)記、庫存、some_unique_id來自 result_table res2聯(lián)合所有選擇標(biāo)記、庫存、some_unique_id來自 tableA@"database_link_name") diff在 (res.some_unique_id = diff.some_unique_id )當(dāng)匹配然后更新集 res.mark = diff.mark,res.stock = diff.stock當(dāng)不匹配時插入(res.mark,資源庫存,res.some_unique_id)價值觀(差異標(biāo)記,差異股票,diff.some_unique_id);

Hypothetically I want to merge 2 tables from different databases into one table, which includes all the data from the 2 tables:

The result would look like something like this:

Aren't the entries in the result table redundant, because there are 2 entries with Porsche and VW? Or can I just add the values in the column 'stock' because the column 'Mark' is explicit?

解決方案

  1. you need to create database link to another database here is the example on how to create database link http://psoug.org/definition/create_database_link.htm after creating your select statement from another database should look: select * from tableA@"database_link_name"
  2. Then you need to use MERGE statement to push data from another database so the merge statement should look something like this.
  3. you can read about merge statement here: https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606

    
    merge into result_table res
    using (select mark, stock, some_unique_id
             from result_table res2
           union all
           select mark, stock, some_unique_id
             from tableA@"database_link_name") diff
    on (res.some_unique_id = diff.some_unique_id )
    when matched then
      update set res.mark = diff.mark, 
                   res.stock = diff.stock
    when not matched then
      insert
        (res.mark, 
             res.stock, 
             res.some_unique_id)
      values
        (diff.mark, 
             diff.stock, 
             diff.some_unique_id);
    

這篇關(guān)于合并來自不同數(shù)據(jù)庫的 2 個表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標(biāo)記轉(zhuǎn)換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計算值創(chuàng)建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 欧美理论 | 天天爱天天操 | 综合久久久久 | 精品国产乱码久久久久久闺蜜 | 99re66在线观看精品热 | 成人午夜电影在线观看 | 亚洲精品久久久9婷婷中文字幕 | 一区二区三区在线电影 | 精品一区二区三区不卡 | 国产高清精品在线 | 国产精品二区三区在线观看 | 午夜视频精品 | 色网站入口 | 亚洲一区在线播放 | av免费网址 | 日韩一级免费电影 | 久久精品色视频 | 色婷婷综合网 | 91香蕉嫩草 | 国产午夜精品一区二区三区四区 | 国色天香综合网 | 九九久久精品 | 91 久久 | 午夜一区二区三区在线观看 | 男女免费视频网站 | 亚洲精品久久久久中文字幕欢迎你 | 成人免费视频在线观看 | 免费在线性爱视频 | 日韩在线成人 | 天天天天天操 | 成人久久视频 | 老司机久久 | 欧美视频第二页 | 精品免费国产视频 | 丁香综合 | 欧美日韩国产精品一区 | 99色视频 | 日韩久草| 国产成人在线视频 | 久久精品亚洲成在人线av网址 | 国产日韩精品在线 |