Oracle 11g
When the SQL statement does not add an order by, it appears that the result is returned in the order of ROWID.
I've also seen some of the relevant documentation, and the official meaning of Oracle is that without order by, the order of output is not guaranteed .
So, here's the question:
If now I select XXX, a group of results come out, the order is .... A.... B.....
So what do I do next, and then make the same select, how can I make the result become .... B... A.....
Notice1: Do not modify the table's primary key in the operation, do not use DDL, only select * from A;
Notice2:
CREATE TABLE A (ID number () primary key, name VARCHAR2 (30));
INSERT into A values (1, ' one ');
Insert into a values (2, ' both '); select * from A;
I have tried some operations, such as Update,insert,delete one or two data, to change the relative order of two results.
Given This requirement:
Don't change the SQL select * from table A
.
Change the table A to change the results order
The answer is a clear and definite:this are not possible.
(Keeping my initial answer as a reference)
"I know the results rowid
would be sorted by"-No, they is not.
The rows would be returned in any order the database thinks are the most efficient.
There is no, absolutely no, guarantee this rows is returned in any specific order unless your specify an ORDER BY
.
The only-to-get-a specific order is ORDER BY
-to-use.
Http://stackoverflow.com/questions/20186673/in-oracle-11g-how-to-change-the-order-of-the-results-of-a-sql-without-order-by
rowID is the uniqueness of the identity row, format: Data Object number (6 characters) +relative file number (3 characters) +block number (6 characters) +row number (3 characters)
The theoretical basis of the database is the set theory, is essentially unordered, do not use ORDER by (subquery or query) is not guaranteed sequence, you can not keep the data out of order to add an estimate to see this phenomenon, but most of the time is the order on the disk, which is related to how the database read data
Http://zhidao.baidu.com/link?url=F6VOk6Khxty3AmU9CgVRrdaBf7UBSsQU6wKLnmqE2XxQ75P_ 4nttqymarqagojk6q-ctyxxk1jiiayqt1dhagvebdyo9mj571vrusfbd2jo
In Oracle 11g, how to change the order of the results of a SQL without "order by"?