|Lesson 2||What is a view? |
|Objective|| Understand what an SQL View is.|
What is View in SQL ?
Views are like windows to the data in your system. If you think of a view like a window to the outside world, the window always gives
you the same relative look at things, but also shows changes that pass in front of it. Views are stored queries that you can call on later to retrieve information from the tables.
The SlideShow shows this idea graphically.
SQL View Defined.
A view starts as a SELECT statement, with all the capabilities that you have come to know from SELECT.
You can also think of a view as a query that is remembered by the engine.
The really neat thing about views is that you can refer to them as tables. For example, suppose you have the following table:
You can create a view of the table that includes only those customers with a state of "UT".
As usual, to create a basic SQL statement that does this, you would use the following:
SELECT * FROM CustomerTable
WHERE State = 'UT'
Once you have this query, it would be nice to refer to it by name, retrieving the values from the query without having to write the whole SQL statement over again?
That is where views come in.
In Access, views are equivalent to queries.
Queries can be saved, and queries can be the target of SELECT statements in other queries. You may have to determine the specific name used by your engine if it supports views. In some engines,
you will hear views called stored queries, saved queries, or virtual views.