mahesh mahesh - 4 months ago 9x
SQL Question

Difference between View and table in sql

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.


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