Results 1 to 3 of 3

Thread: sort order

  1. #1
    Join Date
    Dec 2002

    Unanswered: sort order


    Can anyone please tell me what is default sort order while inserting data using select stmt in ASE12.5.


    insert into tab2 (col1,col2,col3)
    select distinct col1,col2,col3
    from tab1
    where col4 is not null.

    tab1 has clustered index on col4
    tab2 has unique clustered index on col3,col2,col1

    which way data will be inserted
    sorted according to select list ?
    sorted based on clustered index? ( i dont think so)
    any other option?

    Any help in this is appreciated.

    thanx in advance,

  2. #2
    Join Date
    May 2005
    South Africa
    Provided Answers: 1
    There is no default order. If you do not specify an order by clause then there is no guarantee that the same query will always produce the results in the same sequence.

  3. #3
    Join Date
    Jan 2003
    Geneva, Switzerland
    If the table is not partitioned, and if it uses page-level locking (APL), then the default order for the rows being retrieved will probably conform to the clustered index.

    In all other cases the default order is unknown.

    So, as pdreyer says - you should NEVER rely on the rows from a query being returned in a particular order when you don't specify an ORDER BY clause.


Posting Permissions

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