SQL Tutorial: Views
SQL Tutorial
SQL Tutorial
 Back to Help
 1. Introduction
 2. A Simple Query
 3. Common Searches
 4. More Samples
 5. Multiple Tables
 6. Aggregate Fcns.
 7. Group By
 8. Order By
 10. Functions
 11. Conclusion


Look again at the left column of the Schema Browser. You already know what a table is - a storehouse for data of the same type. But what about those other terms?

A view is a virtual table created by combining records from real tables. The records that make up a view remain in their original tables, but they can be accessed and searched through the view.

What does this mean for you? If you're a database programmer, the difference is crucial. For the rest of you, the difference is... nothing. For the purpose of searching for data, a view is a table, and a table is a view. You can search views just like tables, by listing them in the from block.

In fact, many of the so-called "tables" you have been using are actually views! The specObj "table" is actually a view created from the specObjAll table, which contains both good and bad spectra. The PhotoPrimary, Star, Galaxy, and Unknown databases are all views created from the PhotoObjAll table. You've been using these views all along!

Try searching the same area of sky using the SpecObjAll table and the SpecObj view, or the PhotoObjAll table and Star, Galaxy, or Unknown views. What differences do you see?

One particularly important view is the SpecPhoto view, which contains photometric and spectroscopic information on the same objects. Using SpecPhoto is just like doing a join between SpecObj and PhotoObj, but SpecPhoto is easier to use, and your queries will run faster.

When you are ready to move on, click Next to learn about functions.


Enter your SQL query in the text box. The query is limited to 90 seconds and 100,000 rows.