敢达ol全装甲zz导弹:sql 语句如何合并两个表?

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/28 06:49:31
表一:表名为customer1,字段有id,content;
表二:表名为customer2,字段有id,content;

id为主键,不允许重复值。现在想将表一中的数据加入表二中,id相同的不需加入,用sql语句怎么写?请高手帮忙。数据库系统为oracle。

使用not in啊。
insert into customer2 select * from customer1 where id not in(select id f
rom customer2);

a,b两个表合并:
用:
select * from customer1 union select * from customer2
或:
insert into customer2 select * from customer1