What is the difference between SELECT data from table directly or from view?
And What is the best use for each one?
views:
490answers:
4In most databases, they are functionally interchangeable (disregarding materialized views, which are something entirely different anyway.) There are two common reasons for creating views. 1. An abstraction (and column-aliasing) mechanism, and 2. For permissions and access control. But as for efficiency, it's not an issue.
Think of it this way:
A view is just a select statement that lives on the server and has been compiled by the SQL engine.
Usually views are used to limit/simplify the results from the table.
Regards K
It depends on the database and the definition of the view.
A simple view that aliases columns or performs simple calculations will not be different from making the query directly.
However, in some cases the views can be much slower. An example: In Oracle, if you nest view queries too much (e.g. one view uses another as a table, which uses another, etc.), you can create awful performance.
In general you need to test with the specific database and queries in question.