Solved

Import and export in Oracle different row orders in the table

Posted on 2012-03-30
7
450 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 76

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 73

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 73

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 73

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Via a live example, show how to take different types of Oracle backups using RMAN.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now