Does ordered hint in oracle also decides the order of rows in which they are fetched?

390 Views Asked by At

I read that 'The ORDERED hint causes Oracle to join tables in the order in which they appear in the FROM clause.'

But does it also fetch the rows in specific order?

For example: If I have ordered hint on column emp_code which has values as 'A','B' and 'C'[lets consider that more than 2 tables are joined to get emp_code ].

Will the output always have the specific order of rows? For example will 'A' always be the first row and 'C' be the last? does it decides the order of rows? and if yes then how?

1

There are 1 best solutions below

0
On

No. The only thing that controls the order of rows in the final result set is the use of the ORDER BY clause in the SELECT statement. Hints are to influence the access plan chosen by the optimizer, not ordering of the result set.

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
;