如果两个值相等,order by子句如何工作?

编程入门 行业动态 更新时间:2024-10-21 17:44:35
本文介绍了如果两个值相等,order by子句如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的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子句如何工作?

本文发布于:2023-10-26 23:59:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子句   两个   工作   order

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!