oracle - What if the value of order field is the same for all the records -
this question has answer here:
all, let's sql looks below.
select a, b ,c table1 order c
if rows in table1
have same field value in field c. want know if result has same order each time executed sql.
let's data in table1
looks below.
a b c ------------------------------------------- 1 x1 2014-4-1 .... 100 x100 2014-4-1 .... 1000 x1000 2014-4-1 ....
how oracle determine rows sequence same order value?
added
will random sequence each time?
one simple answer no. there no guarantee order by
on equal values return same sorted result every time. might seem stable, however, there many reasons when change.
for example, sorting on equal values might defer after:
- gathering statistics
- adding index on column
for example,
let's have table t:
sql> select * t order b; b ---------- ---------- 1 1 2 1 3 2 4 2 5 3 6 3 6 rows selected.
the sorting on column having similar values like:
sql> create table t1 select * t order b, dbms_random.value; table created. sql> select * t1 order b; b ---------- ---------- 1 1 2 1 4 2 3 2 5 3 6 3 6 rows selected.
so, similar data in bot tables, however, order by
on column having equal values, dos not guarantee same sorting.