applies to: oracle 8+
oracle 8i introduced a new feature called a "materialized view". you define it just like any other view, except that you add the keyword materialized:
create materialized view view_name
a materialized view is like a combination of a table and a view. like a view, it is defined as a logical view into the data of one or more tables. when you update the tables, subsequent queries of the view see the updated data. however, like a table, its data is stored in the database. also, like a table, it is faster if you define indexes for it.
a regular view is stored as a mapping of data from tables. when you modify the data in the tables, the view is completely ignored. when you access the view, it joins the data currently in the tables, and returns the data you requested. a materialized view is stored as such a mapping along with a copy of the actual data from the tables. when you modify the data in the tables, the view's copy of the data is also updated. when you access the view, the data is drawn directly from the copy.
thus a materialized view makes table updates a little slower, but makes view queries much faster. it also consumes additional space in the database.
you could accomplish the same effect by defining an additional table instead of the view, and using triggers on the component tables to update it each time they are changed. however, using a materialized view is more convenient, more efficient, and clearer to the next person who has to maintain your database.
thanks to andy glick for sending me a sample of a materialized view from his application!
--fred
pl/sql tips
this section contains tips on pl/sql statements -- the oracle "procedural language" superset of sql that you use to write stored procedures.
sql navigator tips
this section contains tips on the sql navigator tool by quest systems. it is a graphical front end to the oracle database, allowing you to create, delete, view, and modify all oracle objects: tables, views, stored procedures, etc.
see also
last updated: 6/6/1999
applies to: oracle 7.3+
the following are good sources of info about oracle:
- koch, george, and kevin loney. oracle 8, the complete reference. berkeley ca: for oracle press by osborne mcgraw-hill, 1997. isbn 0-07-882396-x.
this book includes introductory database concepts as well as a complete reference to oracle sql and pl/sql statements. the companion cd contains a complete copy of the book, so you can read it on-line, search it, etc. - any of the o'reilly books. i've been very impressed by all of the o'reilly books since my early unix and x-windows days in the 80's, and they have a complete series on oracle, covering pl/sql, the standard packages, etc.
--fred
ms sql server tips
sql tips
this section contains tips on sql (structured query language) statements in ms sql server.
dynamic sql in a stored procedure
last updated: 2/7/1999