Results 1 to 9 of 9

Thread: Please help with a valid explanation

Threaded View

  1. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Please help with a valid explanation

    UNION has an implicit sort operation. This facilitates identification of similar records since they will end up as adjacent after the sort and before reduction. Implicit sort will sort on the columns as they appear in the column list, namely col1 ascending then col2 ascending. Your results are the same because of your data, the sort order of 1,2,3 is similar to x,y,NULL. try reversing the values as 3,2,1 paired with x,y,NULL

    UNION ALL just appends records from succeeding SELECT statements without additional sort+reduce operation, that is why it's performance is better and why you should use it if records from SELECT statements are mutually exclusive (no similar records, or in terms of venn diagram the sets do not intersect).

    DUAL is just a system table with one column and one record since some operations need to be done in SQL context (not possible in PL/SQL context). In the case of your query you need to generate an SQL resultset but you are not querying from any particular table you created, or you don't want to go through the trouble of creating a pipeline function that returns records. Another use (in older versions of Oracle) is to retrieve next value from sequence object because it is not possible to do so from PL/SQL context.

    SELECT your_sequence_obj.next_value
    INTO a_variable_you_declared_or_assigned_directly_to_column_if_used_in_trigger
    FROM DUAL

    Providing the DUAL table with SYS schema instead of leaving it to users to create their own single row, single column table implementation gives Oracle more control in tuning operations involving the DUAL table. In latter versions, it is made more efficient as it is no longer treated simlar to an ordinary table.
    Last edited by leinad31; Aug 26th, 2010 at 11:03 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width