0

I have two tables for instance Table A and Table B.

Table A and B has same number of columns, but table A has few extra rows.

I was wondering if there's a query that would compare Table A and B and delete the extra number of rows that exist in Table A.

And also it would be good to have a temp table that would the values that were deleted. A

Any suggestions?

4

2 回答 2

0

试试这个:[编辑]

Delete from A where id in 
             (
                Select id from ((select id from A) minus (select id from B))
             );

上面的查询假设 A 和 B 具有相同的列,其中包括一个 id 列 [这是唯一的]。

于 2013-10-22T09:12:34.937 回答
0
select * from tableA a left join TableB b on a.id = b.id

将给出表数据的差异。您可以使用该null值来删除其中的额外数据tableA

于 2013-10-22T11:07:44.957 回答