Netezza Update a Table Column by Joining to Another Table

Mehran F Langerudi picture Mehran F Langerudi · Sep 4, 2015 · Viewed 9k times · Source

I am getting an error by running an update, but I can not figure out where the issue is in Netezza. I appreciate some help.

ERROR [42S02] ERROR: relation does not exist DEVML_WORK.AGRINSHPUN.A

 update Table A
    set A.COL1 = B.COL2 
    from A left outer join  B 
    on A.CU_NUM=B.CU_NUM;

Answer

Niederee picture Niederee · Sep 4, 2015

In general performance on correlated updates in Netezza is slow. Below are two examples that will get your query to work. The second in my experience speeds up large updates.

-- Slow but works
 update  Table A
    set A.COL1 = B.COL2
    from B
    where A.CU_NUM=B.CU_NUM;

--Faster
update A set col1 = sub.col2
from (select a.rowid as rown, b.COL2
from A a inner join
B b
on a.cu_num= b.cu_num) sub
where rowid = sub.rown;