Solved

Import and export in Oracle different row orders in the table

Posted on 2012-03-30
7
451 Views
Last Modified: 2012-09-02
Hi,


I am trying to understand the import process in oracle here!

So I have a PROD and TEST env.

I did export from PROD and imp into TEST.

I have a table with many rows.

when I do on TEST
SELECT *
FROM TABLE1;

I got different row set order than what I got in PROD!

So, my question is that, why it is different? I am just wondering and I probably I can use ORDER BY to get the same, but I am curious about the results without order by clause!
0
Comment
Question by:alcsoft
  • 3
7 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 175 total points
ID: 37787728
The only way in Oracle to guarantee row order is to use an order by.

Select order w/o the order by has no meaning.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 175 total points
ID: 37787735
that makes sense.

the physical order of the data has no reliable influence on the result set.

you may have parallel operations that read data in chunks and the merging of those produced different ordering

if you want your data to be sorted a certain way, the ONLY way that is reliable is to use an ORDER BY

everything else, even if it looks like it returns the same results a million times in a row has no bearing on future results.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37787745
note, that's not just an Oracle thing.  The same is true (or at least, is "supposed" to be true) for any relational database.

SQL works in set-based operations.  Sets have no ordering.
0
 
LVL 1

Expert Comment

by:brentgee
ID: 37788363
the table record selects all have an associated rownum with each record. this is a pseudocolumn and is how oracle selects the records in sql. the order by clause will order it after the selection process. it doesn't matter how the data is inserted, it only matters how it is selected.

if you do an explain plan on the query in each instance, you probably will see slight differences in the plan. this is how the data is selected and thus the rownum will be different.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37788476
brentgee

while what you said about rownum and order by is true,  it doesn't really apply to to this question.

as you can see in the question, rownum is not being queried, so the impact or lack of impact of an order by with rownum is irrelevant.


perhaps you meant rowid instead of rownum, but even so, that's sort of irrelevant as well.
If you select data sorted by rowid and then insert it you still won't have a guarantee of similarly sorted results unless you specify an ORDER BY.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question