使用联合运算符顺序获取数据 [英] Fetch data sequentially using union operator

查看:82
本文介绍了使用联合运算符顺序获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Union运算符获取数据.我希望我的输出与选择查询所取的顺序相同,但是Union会按字母顺序对其进行排序.您能建议我一种避免默认排序的方法吗?

I am fetching data using Union operator. I want my output to be in the same order as my select queries are fetching but instead Union sorts it in alphabetical order. Can you suggest me a way to avoid getting it sorted by default.

推荐答案

Thilo是正确的:为了安全起见,查询应始终明确地对结果进行排序.过去,依靠隐式排序已经引起了很多问题,将来还会继续引起更多问题.

Thilo is correct: to be safe, a query should always explicitly order the results. Relying on implicit sorting has caused many problems in the past and will continue to cause more problems in the future.

几乎总是正确的,关于UNION ALL将避免排序的建议.它应该在11g及以下的版本中工作.但是12c引入了并发执行联合全部,但这不能保证结果的顺序了.

The suggestion that UNION ALL will avoid the sorting is almost always correct. It should work in 11g and below. But 12c introduced concurrent execution of union all, which does not guarantee the order of results any more.

即使隐式排序现在可以正常工作,添加ORDER BY也是一个好主意.

Even if implicit sorting works right now it's always a good idea to add an ORDER BY.

这篇关于使用联合运算符顺序获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆