Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    New York, NY
    Posts
    136

    Question Unanswered: order of records

    Hi,

    I have a small and seemingly silly question...
    I have to Insert data from table A to table B.

    I do a select from table A with an order by clause and insert it into table B.

    Insert into table B (field1, field2, field3) (select field1, field2, field3 from table A order by field1 asc)

    now If i do a simple select * in table B (without any order by clause) will it return data in the same order as the select query on Table A with an order by clause?

    thanks
    rohit

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool



    No, Oracle will insert rows into a table in no particular order.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Moreover, Oracle may fool you if you test it on a small record set - you, actually, might get the same record order after such an INSERT, but that would be an exception to the rule.

    If you want to SELECT records in a particular order, use an ORDER BY clause. Everything else is just a pure twist of luck.

  4. #4
    Join Date
    Sep 2003
    Location
    New York, NY
    Posts
    136
    thanks a lot for the responses

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •