日期:2014-05-17 浏览次数:20964 次
--1、建一个和A表一模一样的临时表,并在hello上建索引 create table tmp_A as select * from A where 1=2; create index tmp_a_idx1 on tmp_a(hello); --2、建立一个临时表tmp_b B表hello字段替冲,并加索引 create table tmp_B as select distinct hello from B; create index tmp_b_idx1 on tmp_b(hello); --3、从A表中随即查出10W条 hello字段不重复的数据插入临时表 tmp_A INSERT INTO TMP_A SELECT 列出A表字段 FROM (SELECT A.*, ROW_NUMBER() OVER(PARTITION BY A.HELLO ORDER BY DBMS_RANDOM.VALUE) ROW_ FROM A WHERE NOT EXISTS (SELECT 1 FROM TMP_B WHERE A.HELLO = TMP_B.HELLO)) WHERE ROW_ = 1 AND ROWNUM <= 100000; --4、将临时表Tmp_a中数据插入B表 insert into B select * from Tmp_a;