首页 > Linux操作系统 > Linux操作系统 > 比较两个表的数据差别
比较两个表的数据差别
在A和B两个用户中,两用户中的inofrmation表结构都是一样的,字段id为主键。
1、A用户表中比B用户表中多出的数据(主要比较主键id)
select * from A.information
where id in
(
select id from A.information
minus
select id from B.information)
2、A用户表和B用户表中,两个表中总共不一样的数据(比较id,name的字段数据)
select id,name from A.information
where id not in (select id from B.information)
union
select id,name from B.information
where id not in (select id from A.information)
3、两个表中id,name相同的记录
select id,name from A.information
intersect
select id,name from B.information
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12778571/viewspace-521232/,如需转载,请注明出处,否则将追究法律责任。