autotrace ansi full outer join : Introduction « Table Joins « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » Table Joins » Introduction 
7. 1. 8. autotrace ansi full outer join
SQL>
SQL>
SQL> create table myTable as
  2  select  'myTable' as C1
  3   ,OBJECT_NAME
  4   ,SUBOBJECT_NAME
  5   ,OBJECT_ID
  6   ,DATA_OBJECT_ID
  7   ,OBJECT_TYPE
  8   ,CREATED
  9   ,LAST_DDL_TIME
 10   ,TIMESTAMP
 11   ,STATUS
 12   ,TEMPORARY
 13   ,GENERATED
 14   ,SECONDARY
 15  from dba_objects;

Table created.

SQL>
SQL> create table myTable2 as
  2  select  'myTable2' as C1
  3   ,OBJECT_NAME  || 'myTable2' as object_name
  4   ,SUBOBJECT_NAME
  5   ,OBJECT_ID
  6   ,DATA_OBJECT_ID
  7   ,OBJECT_TYPE
  8   ,CREATED
  9   ,LAST_DDL_TIME
 10   ,TIMESTAMP
 11   ,STATUS
 12   ,TEMPORARY
 13   ,GENERATED
 14   ,SECONDARY
 15  from dba_objects
 16  where rownum <= 10000;

Table created.

SQL>
SQL> create index myTable_object_id on myTable (object_id);

Index created.

SQL>
SQL> create index myTable2_object_id on myTable2 (object_id);

Index created.

SQL>
SQL> analyze table myTable compute statistics;

Table analyzed.

SQL>
SQL> analyze table myTable2 compute statistics;

Table analyzed.

SQL>
SQL> set autotrace TRACEONLY
SQL> set timing on
SQL> select *
  2  from myTable a, myTable2 b
  3  where a.object_id = b.object_id(+)
  4  union
  5  select *
  6  from myTable a, myTable2 b
  7  where a.object_id(+= b.object_id;

13158 rows selected.

Elapsed: 00:00:00.62

Execution Plan
----------------------------------------------------------
Plan hash value: 4186416997

---------------------------------------------------------------------------------------------
| Id  | Operation                      | Name               | Rows  | Bytes |TempSpc| Cost  |
---------------------------------------------------------------------------------------------
|   SELECT STATEMENT               |                    | 23158 |  4296K|       | 47039 |
|   |  SORT UNIQUE                   |                    | 23158 |  4296K|    10M| 47039 |
|   |   UNION-ALL                    |                    |       |       |       |       |
|   |    NESTED LOOPS OUTER          |                    | 13158 |  2441K|       | 26343 |
|   |     TABLE ACCESS FULL          | MYTABLE            | 13158 |  1169K|       |    27 |
|   |     TABLE ACCESS BY INDEX ROWID| MYTABLE2           |     |    99 |       |     |
|*  |      INDEX RANGE SCAN          | MYTABLE2_OBJECT_ID |     |       |       |     |
|   |    NESTED LOOPS OUTER          |                    | 10000 |  1855K|       | 20022 |
|   |     TABLE ACCESS FULL          | MYTABLE2           | 10000 |   966K|       |    22 |
|   |     TABLE ACCESS BY INDEX ROWID| MYTABLE            |     |    91 |       |     |
|* 10 |      INDEX RANGE SCAN          | MYTABLE_OBJECT_ID  |     |       |       |     |
---------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   - access("A"."OBJECT_ID"="B"."OBJECT_ID"(+))
  10 - access("A"."OBJECT_ID"(+)="B"."OBJECT_ID")

Note
-----
   - cpu costing is off (consider enabling it)


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
      43520  consistent gets
          0  physical reads
          0  redo size
    1301014  bytes sent via SQL*Net to client
      10027  bytes received via SQL*Net from client
        879  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
      13158  rows processed

SQL>
SQL>
SQL> select *
  2  from myTable a full outer join myTable2 b
  3  using (object_id);

13158 rows selected.

Elapsed: 00:00:00.52

Execution Plan
----------------------------------------------------------
Plan hash value: 3236823177

-------------------------------------------------------------------------------------
| Id  | Operation                      | Name               | Rows  | Bytes | Cost  |
-------------------------------------------------------------------------------------
|   SELECT STATEMENT               |                    | 13658 |  4401K| 26365 |
|   |  VIEW                          |                    | 13658 |  4401K| 26365 |
|   |   UNION-ALL                    |                    |       |       |       |
|   |    NESTED LOOPS OUTER          |                    | 13158 |  2441K| 26343 |
|   |     TABLE ACCESS FULL          | MYTABLE            | 13158 |  1169K|    27 |
|   |     TABLE ACCESS BY INDEX ROWID| MYTABLE2           |     |    99 |     |
|*  |      INDEX RANGE SCAN          | MYTABLE2_OBJECT_ID |     |       |     |
|*  |    FILTER                      |                    |       |       |       |
|   |     TABLE ACCESS FULL          | MYTABLE2           |   500 49500 |    22 |
|*  |     INDEX RANGE SCAN           | MYTABLE_OBJECT_ID  |     |    13 |     |
-------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   - access("A"."OBJECT_ID"="B"."OBJECT_ID"(+))
   - filterNOT EXISTS (SELECT /*+ UNNEST */ FROM "MYTABLE" "A" WHERE
              "A"."OBJECT_ID"=:B1))
   - access("A"."OBJECT_ID"=:B1)

Note
-----
   - cpu costing is off (consider enabling it)


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
      45912  consistent gets
          0  physical reads
          0  redo size
     956084  bytes sent via SQL*Net to client
      10027  bytes received via SQL*Net from client
        879  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      13158  rows processed

SQL>
SQL> set timing off
SQL> set autotrace off
SQL>
SQL>
SQL> drop table myTable;

Table dropped.

SQL>
SQL> drop table myTable2;

Table dropped.
7. 1. Introduction
7. 1. 1. Performing SELECT Statements that Use More than Two Tables
7. 1. 2. Three different types of joins:
7. 1. 3. Understanding Non-equijoins
7. 1. 4. Performing SELECT Statements that Use Two Tables
7. 1. 5. Example simple join.
7. 1. 6. Use table alias in table join
7. 1. 7. Convert subqueries to JOINs
7. 1. 8. autotrace ansi full outer join
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.