Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我读到“ORDERED 提示导致 Oracle 按照它们在 FROM 子句中出现的顺序连接表。”
但它是否也按特定顺序获取行?
例如:如果我在列 emp_code 上订购了提示,其值为“A”、“B”和“C”[让我们考虑连接超过 2 个表以获得 emp_code]。
输出是否总是具有特定的行顺序?例如,“A”总是第一行,“C”是最后一行吗?它决定行的顺序吗?如果是,那怎么办?
不,唯一控制最终结果集中行顺序的方法是在 SELECT 语句中使用 ORDER BY 子句。提示是影响优化器选择的访问计划,而不是结果集的排序。
select emp_id, emp_name from emp order by emp_id -- <this is the only thing that controls the order of rows in the result set ;