Newsletter Subscription | Glossary | Contact Us
Home > All Categories > Oracle > SQL and PLSQL > WITH Clause
Question Title WITH Clause
Authored by: Patrick Barel
Viewed: 368 times so far

During my work for AMIS I came across a (to me at least) new feature of the SQL engine. Instead of building an inline view in the from clause of a statement you can build this ‘inline view’ before the SQL statement and use the results in the from 9ifinalclause. The syntax is pretty straightforward:

WITH < your_alias > AS ( < select_statement > )
SELECT < fieldlist >
FROM < tables, >< your_alias >
WHERE < where_clause > ;

It was quite puzzling to me at first, but I can definitely see possibilities here. Not only is this approach probably more readable than using inline views, but according to Oracle this approach is also much faster.

Improving Query Performance with the SQL WITH Clause tells me a couple of things. First of all, this feature was introduced in Oracle 9 i (which makes is apparent that I didn’t know of this feature, because 1) I didn’t need it before and 2) my major customers at my previous employer were still running Oracle 8 i). Second, this feature is supposed to speed up query execution. If for instance you have multiple references to the same query, you can of course copy and paste it’s contents in the query, but that is not really Single Point Of Definition. And the query has to be parsed and executed multiple times where the result should be the same at all times. Of course you can circumvent this issue by creating a real view in the database, but there are times when you don’t want that, because you eiter don’t want to expose the query logic, or you don’t have the rights to do this.

Read the rest of this article at http://bar-solutions.com/wordpress/?p=219
Click Here to View all the questions in SQL and PLSQL category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
User Comments User Comments
There are no user comments for this question. Be the first to post a comment. Click Here
Post Comment Add a Comment
Email Address:
Comment/Message
Verify Code

Post Comment How helpful was this article to you?
Related Questions Related Article
  1. Oracle 11G - Compound Trigger
  2. Parameters in Oracle
  3. Oracle 11G - Virtual Columns (Dates)
  4. Constraints and Row Level Security
  5. Union vs Union All
  6. Ansi SQL vs Oracle SQL
  7. Simple comparison SQL
  8. Oracle 11G - Follows in Trigger
  9. Tri-state boolean
  10. Cascading Delete
  11. Conditional Compilation...
  12. Oracle 11G - Virtual Columns
  13. Recursive programming.
  14. Handy date functions
  15. A boolean property that's really an integer.
  16. Ordering Results
  17. Oracle errors
  18. Shrinking tablespaces
  19. Testing Rulegen using Codetester
  20. Functions as default values
  21. By position or by name.
  22. Defaults
  23. Open cursors
Article Information Additional Information
Article Number: 348
Created: 2008-07-16 2:44 AM
Rating 5 Stars
 
Article Options Article Options
Print Question Print this Question/Article
Email Question Email this Question/Article to Friend
Export to MS Word Export to MS Word
Bookmark Article
del.icio.us Bookmark del.icio.us Bookmark
Digg It Digg It
Furl It Furl It
Subscribe to Article Subscribe to Article
 
Language Translation Language Translation
 
Search Knowledge Base Search Knowledge Base