--方法1:使用insert...select加minus INSERT INTO b SELECT col FROM a MINUS SELECT col FROM b; select * from tab;--方法2:使用merge into MERGE INTO b USING a ON (a.col = b.col) WHEN NOT MATCHED THEN INSERT VALUES (a.col);
上面select * from tab;这一行多余
--column为你的列名 insert into b select * from a where a.column not in(select column from b);
--用not exists代替not in ,not in无法识别子查询中有NULL的值insert into b select * from a where not exists (select 1 from b where a.col=b.col );
INSERT INTO b
SELECT col FROM a
MINUS
SELECT col FROM b;
select * from tab;--方法2:使用merge into
MERGE INTO b
USING a
ON (a.col = b.col)
WHEN NOT MATCHED THEN
INSERT VALUES (a.col);
insert into b select * from a where a.column not in(select column from b);
where not exists (select 1 from b where a.col=b.col );