oracle merge鍚屾椂鍖呭惈澧炪€佸垹銆佹敼
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle merge鍚屾椂鍖呭惈澧炪€佸垹銆佹敼相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e7%89%a9%e7%90%86' title='鐗╃悊'>鐗╃悊
this des with 瑕佹眰 update acl while rac鍘熸潵涓€鐩存病娉ㄦ剰锛宮erge鏄彲浠ユ敮鎸乨elete锛屽彧涓嶈繃蹇呴』鐨勬槸on鏉′欢婊¤冻锛屼篃灏辨槸瑕佹眰绯荤粺鏀寔閫昏緫鍒犻櫎锛岃€岄潪鐗╃悊鍒犻櫎銆?/p>
Using the DELETE Clause with MERGE Statements
You may want to cleanse tables while populating or updating them. To do this, you may want to consider using the DELETE
clause in a MERGE
statement, as in the following example:
MERGE USING Product_Changes S
INTO Products D ON (D.PROD_ID = S.PROD_ID)
WHEN MATCHED THEN
UPDATE SET D.PROD_LIST_PRICE =S.PROD_NEW_PRICE, D.PROD_STATUS = S.PROD_NEWSTATUS
DELETE WHERE (D.PROD_STATUS = "OBSOLETE")
WHEN NOT MATCHED THEN
INSERT (PROD_ID, PROD_LIST_PRICE, PROD_STATUS)
VALUES (S.PROD_ID, S.PROD_NEW_PRICE, S.PROD_NEW_STATUS);
Thus when a row is updated in products
, Oracle checks the delete condition D.PROD_STATUS = "OBSOLETE"
, and deletes the row if the condition yields true.
The DELETE
operation is not as same as that of a complete DELETE
statement. Only the rows from the destination of the MERGE
can be deleted. The only rows that are affected by the DELETE
are the ones that are updated by this MERGE
statement. Thus, although a given row of the destination table meets the delete condition, if it does not join under the ON
clause condition, it is not deleted.
以上是关于oracle merge鍚屾椂鍖呭惈澧炪€佸垹銆佹敼的主要内容,如果未能解决你的问题,请参考以下文章
鍗佷竷銆乨bms_tts(妫€鏌ヨ〃绌洪棿闆嗗悎鏄惁鏄嚜鍖呭惈)