这是我的NEWSPAPER表.
This is my NEWSPAPER table.
National News A 1 Sports D 1 Editorials A 12 Business E 1 Weather C 2 Television B 7 Births F 7 Classified F 8 Modern Life B 1 Comics C 4 Movies B 4 Bridge B 2 Obituaries F 6 Doctor Is In F 6当我运行此查询时
select feature,section,page from NEWSPAPER where section = 'F' order by page;它给出了这个输出
Doctor Is In F 6 Obituaries F 6 Births F 7 Classified F 8但是在凯文·洛尼(Kevin Loney)的《 Oracle 10g完全参考》中,输出是这样的
But in Kevin Loney's Oracle 10g Complete Reference the output is like this
Obituaries F 6 Doctor Is In F 6 Births F 7 Classified F 8请帮助我了解情况如何?
Please help me understand how is it happening?
推荐答案在关系数据库中,表是集合,并且是无序的. order by子句主要用于输出目的(以及其他一些情况,例如包含rownum的子查询).
In relational databases, tables are sets and are unordered. The order by clause is used primarily for output purposes (and a few other cases such as a subquery containing rownum).
这是一个不错的起点.当order by上的键相同时,SQL标准未指定必须执行的操作.这是有充分理由的.可以使用不同的技术进行排序.有些可能稳定(保留原始顺序).某些方法可能不是.
This is a good place to start. The SQL standard does not specify what has to happen when the keys on an order by are the same. And this is for good reason. Different techniques can be used for sorting. Some might be stable (preserving original order). Some methods might not be.
着眼于集合中是否存在相同的行,而不是它们的顺序.顺便说一句,我认为这是一个不幸的例子.这本书的示例中不应有歧义.
Focus on whether the same rows are in the sets, not their ordering. By the way, I would consider this an unfortunate example. The book should not have ambiguous sorts in its examples.
更多推荐
如果两个值相等,order by子句如何工作?
发布评论