In Oracle 11g, what does the order of the results of a SQL without "order by"?

Source: Internet
Author: User

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"?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.