Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: views vs stored queries

Re: views vs stored queries

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 14 Dec 1998 13:09:29 GMT
Message-ID: <368b0d95.31518991@192.86.155.100>


A copy of this was sent to gennick_at_worldnet.att.net (Jonathan Gennick) (if that email address didn't require changing) On 14 Dec 1998 04:45:27 GMT, you wrote:

>On Sun, 13 Dec 1998 14:52:46 GMT, tkyte_at_us.oracle.com
>(Thomas Kyte) wrote:
>

> >views are not just stored queries. A view is much more like a
> database table
> >then a stored query.
>
> But aren't they implemented much like stored queries? I mean

views are implemented physically as a stored query yes -- that query gets merged into some (typically) larger query. The text of the original view definition is stored and "select * from THAT_VIEW" will be turned into the original view statement.

How they are implemented tho doesn't mandate how they are used. A view is to be considered a table -- it might be a virtual table (no physical storage for the rows, but the basic set of rules that govern how a table behaves, govern how a view behaves.

If a view was just a stored query -- you couldn't grant "select" on it. You couldn't "select * from view where x = 5" -- you would only be able to "select * from view"... You would only be able to "run that query"

> you basically have a SELECT statement defining the view, and
> that statement is stored in the database. Right? And when
> you select from a view the optimizer makes some decisions
> about how to merge the stored SELECT (the view) with your
> SELECT against that view. Right?
>

yes, that is basically correct.

> I usually do tell people that a view is just a stored query,
> in part because people do get some funny ideas about how
> they are implemented. I've even had people think that a
> view's query was executed at view creation time, creating
> the result set at that point.
>

so do i -- as an analogy. its important for them to realize that it behaves like a table as well in many respects.

>regards,
>
>Jonathan
>
>p.s. I remember years ago trying to use ORDER BY in a view
>definition. Struck me as odd, at first, that I couldn't.
>After thinking about it for awhile though, it makes perfect
>sense.
>
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Dec 14 1998 - 07:09:29 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US