【发布时间】:2013-08-07 17:05:40
【问题描述】:
我在两个模式中有两个表 - schema1 和 schema2。 这两个表具有相同的设计,只是 Schema2 在表的主键上有一个聚集索引。
Schema1 表没有主键(这就是旧设计的方式,我必须使用新的架构设计来改进它,即 schema2)
在模式 2 中, COL_1 是 table1 的主键, (COL_4, COL_12 ) 是 table2 的索引键。
表 1 (col_1, col_2, col_3, col_4 ... col_10) 表 2(col_1,col_4,col_12, .... col_20)
我有一个从table1中检索数据的查询,如下
SELECT t1.COL_1,t1.COL_2, t1.COL_3, t1.COL_4,t1.COL_5
FROM table1 t1
LEFT JOIN table2 t2 ON
t2.COL_1 = t1.COL_1,
AND t2.COL_4 = t1.COL_4
WHERE
t1.col_10 = '/some string/'
当我在两种模式中运行此查询时,我得到的检索行数相同。 但是行的顺序不一样,我不知道如何比较两者中的数据。
我的问题。
- 我可以假设两个模式中的结果都匹配,只是因为行数匹配?
- 如果因为 schema2 中的表中有索引,结果会有所不同吗?
我想了解上述行为。
提前致谢。
【问题讨论】:
-
Can I assume that both the results in the two schemas match, just 'coz the rowcount match ?我不会。Do the results differ if since there is index in the tables in schema2 ?关于订单大概。检查执行计划确认
标签: sql sql-server-2008 select clustered-index