Difference between View and table in sql

Mahesh KP picture Mahesh KP · May 16, 2011 · Viewed 295.8k times · Source

Possible Duplicate:
Difference Between Views and Tables in Performance

What is the main difference between view and table in SQL. Is there any advantage of using views instead of tables.

Answer

Aaron Digulla picture Aaron Digulla · May 16, 2011

A table contains data, a view is just a SELECT statement which has been saved in the database (more or less, depending on your database).

The advantage of a view is that it can join data from several tables thus creating a new view of it. Say you have a database with salaries and you need to do some complex statistical queries on it.

Instead of sending the complex query to the database all the time, you can save the query as a view and then SELECT * FROM view