[英]I have 2 tables, same structure but in 2nd table some rows missing. How do you update table 2nd table without using update and joins? using sql
我有2個表,結構相同,但在第2個表中缺少一些行。 如何在不使用更新和聯接的情況下更新表2nd?
使用SQL
您應該正在查看合並。
MERGE INTO table2 tb2
USING table1 tb1
ON tb2.col1 = tb1.col1
and tb2.col2 = tb1.col2
.
.
.
<more columns>
WHEN MATCHED THEN
UPDATE
SET tab2.col1 = tab1.col1
.
.
.
<columns you wand to update>
WHEN NOT MATCHED THEN
INSERT (tab2.col1, tab2.col2 .....<all columns>))
VALUES (tab1.col1 , tab1.col1 .....<all columns>);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.