pl-sql
UPDATE table1 a
SET table1_column = (SELECT table2_column
FROM table2
WHERE ID = a.ID)
如果雙方均有KEY值,使用下面這個方法會超快
UPDATE (
SELECT PAYCDL.ID_NO, PAYCDL.DATE_ADD DATE_ADD_OLD,PAYCDL.DATE_LAST_MAINT DATE_LAST_MAINT_OLD,
EXSCCS_PMS2.DATE_ADD DATE_ADD_NEW, EXSCCS_PMS2.DATE_LAST_MAINT DATE_LAST_MAINT_NEW
FROM PAYCDL,
EXSCCS_PMS2
WHERE PAYCDL.ID_NO = EXSCCS_PMS2.ID_NO)
SET DATE_ADD_OLD = DATE_ADD_NEW,
DATE_LAST_MAINT_OLD = DATE_LAST_MAINT_NEW
-----------------------------------
ms-sql
UPDATE table1
SET table1.col = table2.col1
FROM table2 WHERE table2.oldCol = table1.col