由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 请教比较两个table,找出相同和不同的records
相关主题
初级问题请问一个SQL语句的优化问题
请教几个面试题SQL Server 问题 -- 怎样 UPDADATE 才快
oracle中如何查询已建立的表结构SQL fast search in a 10 million records table (转载)
请教一个SQL QueryOracle下如何能得到所有table的名字?
T-SQL Update Statement Questionhow to see all the tables in SQL*PLUS?
How to find intersection of two tables请教一个sql server的问题
compare two large tables SQL (转载)双CPU与SQLServer速度的一个问题
how to particially delete record in sql serverCan I create thousands table in one...
相关话题的讨论汇总
话题: records话题: table话题: server话题: 相同话题: ddd
进入Database版参与讨论
1 (共1页)
n********6
发帖数: 1511
1
请教query,请教比较两个table,找出相同和不同的records
SQL 2005
一个在server 1,一个在server 2。
表结构相同。
表数据不同,有共同拥有的纪录(records),也有各自独有的纪录(records)。
server 1, server 2是 linked server,可以直接query。
table 不大,thousands of records。用于看看到底有什么异同。不考虑performance。
table a, sample:
aid, a_environment, a_description...
1, aaa, abcd,...
1, bbb, xyzn,...
1, ccc, ddeea,...
1, ddd, jdie,...
2, aaa, ...
2, bbb, ...
2, ddd, ...
4, aaa, ...
4, ddd, jjgd,
5, ......
...
table b, sample
bid, b_environment, b_description...
2, aa
m**********2
发帖数: 2252
2
left join

performance。

【在 n********6 的大作中提到】
: 请教query,请教比较两个table,找出相同和不同的records
: SQL 2005
: 一个在server 1,一个在server 2。
: 表结构相同。
: 表数据不同,有共同拥有的纪录(records),也有各自独有的纪录(records)。
: server 1, server 2是 linked server,可以直接query。
: table 不大,thousands of records。用于看看到底有什么异同。不考虑performance。
: table a, sample:
: aid, a_environment, a_description...
: 1, aaa, abcd,...

n********6
发帖数: 1511
3
当时做了outer join,但是好像不是所要的结果。还没想清楚到底怎么做。

【在 m**********2 的大作中提到】
: left join
:
: performance。

d*******8
发帖数: 3182
4
1,先定义一下何为相同何为不同吧。
相同:aid = bid and a_env = b_env and a_desc = b_desc?
2,再确认一下你的思路吧。
你是想用一个宋庆龄 statement来比较在不同的database 色窝中的两个桌子,对吗?

performance。

【在 n********6 的大作中提到】
: 请教query,请教比较两个table,找出相同和不同的records
: SQL 2005
: 一个在server 1,一个在server 2。
: 表结构相同。
: 表数据不同,有共同拥有的纪录(records),也有各自独有的纪录(records)。
: server 1, server 2是 linked server,可以直接query。
: table 不大,thousands of records。用于看看到底有什么异同。不考虑performance。
: table a, sample:
: aid, a_environment, a_description...
: 1, aaa, abcd,...

n********6
发帖数: 1511
5

对。整条记录record完全相同。
不一定。能用就好。当时考虑了outerjoin,把两条记录连起来。
每条记录内aid=bid and a_env = b_env and ...的就是相同的。
排除aid is null and bid is null and 相同的纪录 就是有差异的纪录。后来发现错
了。条件似乎很麻烦。明天上班有空再想。

【在 d*******8 的大作中提到】
: 1,先定义一下何为相同何为不同吧。
: 相同:aid = bid and a_env = b_env and a_desc = b_desc?
: 2,再确认一下你的思路吧。
: 你是想用一个宋庆龄 statement来比较在不同的database 色窝中的两个桌子,对吗?
:
: performance。

w*******e
发帖数: 1622
6
你用binary_Checksum()试试

【在 n********6 的大作中提到】
:
: 对。整条记录record完全相同。
: 不一定。能用就好。当时考虑了outerjoin,把两条记录连起来。
: 每条记录内aid=bid and a_env = b_env and ...的就是相同的。
: 排除aid is null and bid is null and 相同的纪录 就是有差异的纪录。后来发现错
: 了。条件似乎很麻烦。明天上班有空再想。

B*****g
发帖数: 34098
7
不考虑performance?
Use minus.

performance。

【在 n********6 的大作中提到】
: 请教query,请教比较两个table,找出相同和不同的records
: SQL 2005
: 一个在server 1,一个在server 2。
: 表结构相同。
: 表数据不同,有共同拥有的纪录(records),也有各自独有的纪录(records)。
: server 1, server 2是 linked server,可以直接query。
: table 不大,thousands of records。用于看看到底有什么异同。不考虑performance。
: table a, sample:
: aid, a_environment, a_description...
: 1, aaa, abcd,...

b******e
发帖数: 1861
8
a not in b
union all
b not in a
n********6
发帖数: 1511
9
Minus is the right answer for Oracle. Thank you.
In SQLSERVER, I used INTERSECT and EXCEPT and got the result. EXCEPT is teh
'Minus' in SQL.

【在 B*****g 的大作中提到】
: 不考虑performance?
: Use minus.
:
: performance。

1 (共1页)
进入Database版参与讨论
相关主题
Can I create thousands table in one...T-SQL Update Statement Question
急问一个关于T-SQL的问题,谢谢How to find intersection of two tables
interview question (SQL)compare two large tables SQL (转载)
How to find all duplicate record in SQL?how to particially delete record in sql server
初级问题请问一个SQL语句的优化问题
请教几个面试题SQL Server 问题 -- 怎样 UPDADATE 才快
oracle中如何查询已建立的表结构SQL fast search in a 10 million records table (转载)
请教一个SQL QueryOracle下如何能得到所有table的名字?
相关话题的讨论汇总
话题: records话题: table话题: server话题: 相同话题: ddd