Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Insert without a Primary Key

Re: Insert without a Primary Key

From: Robert W. Swisshelm <nospam_at_lilly.com>
Date: 1997/09/04
Message-ID: <340EFD8A.788A@lilly.com>#1/1

Stan Novinsky wrote:
>
> A question:
>
> 150 rows of data are inserted into a table without a primary key.
>
> When a select is executed on the table, will the 150 rows of data be
> retrieved
> in the same order as inserted - (ie. row 1 inserted into the table
> table will always be row 1 retrieved.)
>
> Thanks

As all of the responses state, no, you cannot guarantee that the rows will be returned in the same order.

Think of how oracle processes an insert. It looks for a block on the free list and fills it. It then gets the next block on the free list. That block could be physically before the block that was just used.

Now think of how Oracle handles a full table scan. It scans through the blocks in order and returns the data.

This explains why a newly created table would likely return the rows in order, because Oracle used the blocks in sequence. However, as you perform deletes and updates, Oracle will begin inserting rows all of the place, so your data won't be returned in order.

-- 
Bob Swisshelm
Eli Lilly and Company
nospam.swisshelm_at_lilly.com  
(remove 'nospam' if you want to send mail to me)
Received on Thu Sep 04 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US