三张表结构相同,怎么高效率的把其中两张表的数据插入到另一张表,并且插入的数据不能有重复? 有三张表结构相同的表T1、T2、T3,现在想把T1、T2表中的数据插入到T3中,并且ID不能有重复的(T1与T2中如有互相重复的数据,应去重后只保留一条),每张表中的数据都有几十万条,请问高手怎么写SQL语句才能高效的完成此任务? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 insert into t3(select * from t1 union select * from t2) 当你在id上有unique index的时候,通过两步的插入即可.insert into t3 select * from t1;insert into t3 select * from t2 where not exists (select 1 from t3 where t3.id=t2.id);几十万条算不了什么数据,就是用最普通的in也耗费不了多少时间. windows 2003 32位下开启应用后oracle占用内存不断上升 表分析后sql查询反倒变慢? 请教查询时,to_date的问题 orcal怎么查哪用户操作过? 把序列重新设为“1”,怎么实现?(Oracle 9i中) 这个查询为什么会有值? 如何启动数据库 有关update的问题(在线等待,马上给分!!) Oracle中重复率高字段创建B树索引,性能大幅提升的原因 高水位疑惑 一对多 SQL 语句求教 ORACLE简单问题
(select * from t1
union
select * from t2)
insert into t3 select * from t2 where not exists (select 1 from t3 where t3.id=t2.id);几十万条算不了什么数据,就是用最普通的in也耗费不了多少时间.