Results 1 to 3 of 3

Thread: sort order

  1. #1
    Join Date
    Dec 2002
    Posts
    104

    Unanswered: sort order

    Hello,

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

    example:

    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,
    Pooja

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    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
    Location
    Geneva, Switzerland
    Posts
    353
    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.

    Michael

Posting Permissions

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