SELECT B.WMS_CLHADT, B.WMS_CLHA_CLASS, C.ORDER_STATUS FROM EM_HMNW_RECIPT_HIS_TEST A, EM_ORDER_DETAIL_TEST B, EM_ORDER_GOODS_TEST C WHERE B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ)셀렉트 하면 967건의 데이터 가 나오는데요 세개의 컬럼을 업데이트 하려고 합니다. B.WMS_CLHADT = '' B.WMS_CLHA_CLASS = '' C.ORDER_STATUS = '10' 으로 업데이트하려는데요 고수님들의 조언부탁드립니다^^
UPDATE EM_ORDER_GOODS_TEST SET ORDER_STATUS = '77' WHERE ORD_NUM IN ( SELECT A.ORD_NUM FROM EM_HMNW_RECIPT_HIS_TEST A, EM_ORDER_DETAIL_TEST B, EM_ORDER_GOODS_TEST C WHERE B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) ) AND GOODS_ID IN ( SELECT A.GOODS_ID FROM EM_HMNW_RECIPT_HIS_TEST A, EM_ORDER_DETAIL_TEST B, EM_ORDER_GOODS_TEST C WHERE B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) ) AND ORD_DEAL_SEQ IN ( SELECT A.ORD_DEAL_SEQ FROM EM_HMNW_RECIPT_HIS_TEST A, EM_ORDER_DETAIL_TEST B, EM_ORDER_GOODS_TEST C WHERE B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) ) 요렇게하니까 968건이 업데이트되네요 ㅠㅠ 뭔가잘못하고있는거죠..
맨위 질의 올려주신 SELECT B.WMS_CLHADT, B.WMS_CLHA_CLASS, C.ORDER_STATUS FROM EM_HMNW_RECIPT_HIS_TEST A, EM_ORDER_DETAIL_TEST B, EM_ORDER_GOODS_TEST C WHERE B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) 요게 967건 뜬고 업데이트 967건 되어야 한다면. 일단 C는 다음과 같이 하시면 될거 같습니다. update EM_ORDER_GOODS_TEST c set ORDER_STATUS = '10' where exists( select 1 from EM_HMNW_RECIPT_HIS_TEST A, EM_ORDER_DETAIL_TEST B where B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) );
B는 말씀주신 것처럼 바꿔쓰시면 될거 같아용.
update EM_ORDER_GOODS_TEST c set ORDER_STATUS = '99' where exists( select 1 from EM_HMNW_RECIPT_HIS_TEST A, EM_ORDER_DETAIL_TEST B where B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) );하면 5분이 지나도 업데이트가안되네요
update EM_ORDER_GOODS_TEST c set ORDER_STATUS = '57' where exists( SELECT 1 FROM EM_HMNW_RECIPT_HIS_TEST A, EM_ORDER_DETAIL_TEST B, EM_ORDER_GOODS_TEST C WHERE B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) );으로하니까 12만건이 업데이트되네요 ㅠㅠ
-- ORDER_STATUS = '' 업데이트 쿼리 UPDATE EM_ORDER_GOODS SET ORDER_STATUS = '18' WHERE 1=1 AND (ORD_NUM, GOODS_ID, ORD_DEAL_SEQ) IN ( SELECT C.ORD_NUM, C.GOODS_ID, C.ORD_DEAL_SEQ FROM EM_HMNW_RECIPT_HIS A, EM_ORDER_DETAIL B, EM_ORDER_GOODS C WHERE B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) ) -- WMS_CLHA_CLASS = '', WMS_CLHADT = '' 업데이트쿼리 UPDATE EM_ORDER_DETAIL SET WMS_CLHA_CLASS = '', WMS_CLHADT = '' WHERE 1=1 AND (ORD_NUM, GOODS_ID, GOODS_SEQNO) IN ( SELECT C.ORD_NUM, C.GOODS_ID, C.ORD_DEAL_SEQ FROM EM_HMNW_RECIPT_HIS A, EM_ORDER_DETAIL B, EM_ORDER_GOODS C WHERE B.WMS_CLHADT = TO_DATE ('20130902', 'YYYYMMDD') AND (A.ORD_NUM = B.ORD_NUM AND A.GOODS_ID = B.GOODS_ID AND A.ORD_DEAL_SEQ = B.GOODS_SEQNO) AND (A.ORD_NUM = C.ORD_NUM AND A.GOODS_ID = C.GOODS_ID AND A.ORD_DEAL_SEQ = C.ORD_DEAL_SEQ) ) 이렇게 해결하였습니다. 매우매우 감사합니다. 그런데 마농님께서 인덱스 만들라구 하셧는데 인덱스 무었인가요? 테이블 인덱스 만들기로 검색해도 안나와서 질문드립니다(__)