How to insert distinct values in database user java language? 在java里面实现,请明示!
MERGE INTO table a USING (SELECT cols1,cols2,cols3 ... FROM tableb) b ON (a.cols1 = b.cos1) WHEN NOT MATCHED THEN -不存在,就插入 INSERT (cols1,cols2,cols3 ...) VALUES (b.cols1,cols2,cols3 ...) WHEN MATCHED THEN --存在就UPDATE,这个你可以不要的 UPDATE SET a.cols1 = b.cols1, a.cols2 = b.cols2, a.cols3 = b.cols3 ... where a.cols1 = b.cols1
insert into a select col1,col2.. from (select col1,col2.. from b where not exists (select 1 from a where a.name=b.name and a.itemID=b.itemID and a.createDate=b.craeatedate) )
insert into TableA (select distinct * from TableA) 试下这个方法
1:将要插入的数据插入一张表中,把表的logging改成nologging,先把数据load进去,加并行度,然后再分析合并。 2:MERGER INTO
2.用NOT EXISTIS进行判断,不存在的再插入,,肯定不需要用FOR实现,,
不明白看我空间加我Q
在java里面实现,请明示!
USING (SELECT cols1,cols2,cols3 ...
FROM tableb) b
ON (a.cols1 = b.cos1)
WHEN NOT MATCHED THEN -不存在,就插入
INSERT (cols1,cols2,cols3 ...)
VALUES (b.cols1,cols2,cols3 ...)
WHEN MATCHED THEN --存在就UPDATE,这个你可以不要的
UPDATE
SET a.cols1 = b.cols1, a.cols2 = b.cols2,
a.cols3 = b.cols3 ...
where a.cols1 = b.cols1
然后 看看中间表的数据是否有规律,比如说有一个字段有规律,按照这个字段进行where条件写入,让commit的数量不是特别大就可以了。
select col1,col2..
from (select col1,col2..
from b
where not exists
(select 1
from a
where a.name=b.name
and a.itemID=b.itemID
and a.createDate=b.craeatedate) )
试下这个方法
1:将要插入的数据插入一张表中,把表的logging改成nologging,先把数据load进去,加并行度,然后再分析合并。
2:MERGER INTO