我从 Oracle sql 工具运行插入,从各种表中选择大约 100.000 行并将它们插入到不同数据库的另一个表中,这在 3 分钟内结束。我在 oracle 中的存储过程或 PLSQL 中尝试了相同的查询,我们运行了大约 2 个小时。有关信息,我使用 Source Oracle 11g 和目标 Oracle 10g
存储过程(每个存储大约需要 2 小时):
CREATE OR REPLACE PROCEDURE MGS.TRANSFER_DATA(a_date in varchar2) -- yyyymmdd
BEGIN
BEGIN
FOR xx IN(
SELECT STR_CD FROM MGS.STORE ORDER BY STR_CD ASC
) LOOP
CALL_LOG(xx.STR_CD,a_date,sysdate,"START INSERT");
INSERT INTO STOCK@BBS
SELECT
STR_CD, STK.DT, PROD_CD, QTY, ORDER_QTY, ORDER_QTY
FROM
MGS.STOCK STK, MGS.SALE SAL
WHERE STK.STR_CD = xx.STR
AND STK.STR_CD = SAL.STR_CD(+)
AND STK.PROD_CD = SAL.PROD_CD(+)
AND STK.DT = SAL.DT(+)
AND STK.DT = a_date;
CALL_LOG(xx.STR_CD,a_date,sysdate,"INSERT SUCESSFULL");
END LOOP;
END;
结束传输_数据;
我尝试查询 1 家商店(只需 3 分钟):
INSERT INTO STOCK@BBS
SELECT
STR_CD, STK.DT, PROD_CD, QTY, ORDER_QTY, ORDER_QTY
FROM
MGS.STOCK STK, MGS.SALE SAL
WHERE STK.STR_CD = 'STORE01'
AND STK.STR_CD = SAL.STR_CD(+)
AND STK.PROD_CD = SAL.PROD_CD(+)
AND STK.DT= SAL.DT(+)
AND STK.DT= '20120801'; -- yyyymmdd