Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

Advanced Oracle SQL: Table Expressions

Oracle Tips by Laurent Schneider

 

Laurent Schneider is considered one of the top Oracle SQL experts, and he is the author of the book "Advanced SQL Programming" by Rampant TechPress.  The following is an excerpt from the book.

1.      Table expression

Table expressions could be a view, a table, a collection or a remote table:

SELECT
   *
FROM
   EMP; 

EMP is a table: 

SELECT
   *
FROM
   TABLE
   (
      SYS.ODCINUMBERLIST(1,2,3)
   );

COLUMN_VALUE
------------
           1
           2
           3
-------------------------------------------------------------------------------------------
| Id  | Operation                             | Name | Rows  | Bytes | Cost (%CPU)|  Time     |
-------------------------------------------------------------------------------------------|   0 | SELECT STATEMENT                      |      |  8168 | 16336 |    29   (0)| 00:00:01 |
|   1 |  COLLECTION ITERATOR CONSTRUCTOR FETCH|      |       |       |           
|          |
-------------------------------------------------------------------------------------------

SYS.ODCINUMBERLIST is a varying array (or varray) of NUMBER. ODCIDATELIST (10g) is an array of DATE, ODCIRAWLIST (10g) is an array of RAW(2000) and ODCIVARCHAR2LIST (10g) is an array of VARCHAR2(4000).

Note the inaccurate row count!

TABLE is a function that transforms the collection in a table. It can be used with NESTED TABLES or VARRAY columns, with type constructs, and with functions returning a collection:

SELECT
   COUNT(*)
FROM
   EMP@DB02;
  COUNT(*)
----------
        14

----------------------------------------------------------------------------------
| Id  | Operation              | Name   | Rows  | Cost (%CPU)| Time     | Inst   |
----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT REMOTE|        |     1 |     1   (0)| 00:00:01 |        |
|   1 |  SORT AGGREGATE        |        |     1 |            |          |        |
|   2 |   INDEX FULL SCAN      | PK_EMP |    14 |     1   (0)| 00:00:01 |  LSC01 |
----------------------------------------------------------------------------------

DB02 is a database link. EMP@DB02 is a remote table. Note the Inst column and the SELECT STATEMENT REMOTE operation:

SELECT
   ENAME
FROM
   EMP_PART
PARTITION
(
   EMP_P10
);

ENAME
----------
CLARK
KING
MILLER

-------------------------------------------------------------------------------------------
| Id  | Operation             | Name     | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |          |     3 |   108 |     3   (0)| 00:00:01 |       |       |
|   1 |  PARTITION LIST SINGLE|          |     3 |   108 |     3   (0)| 00:00:01 |     1
|     1 |
|   2 |   TABLE ACCESS FULL   | EMP_PART |     3 |   108 |     3   (0)| 00:00:01 |     1
|     1 |
-------------------------------------------------------------------------------------------

EMP_P10 is a partition of the EMP_PART table.

Summary

The SELECT syntax contains the expressions to be selected, the tables and subquery to select from, the conditions where rows are returned, the group by clause that aggregate rows, the connect by clause to use hierarchy and the model clause. The join can be written in Oracle or in ANSI syntax and the outer join can select columns of one table even when there is no matching row. The commonly used set operators are UNION, UNION ALL and MINUS.

 


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.