tags:

views:

348

answers:

5

If views are used to show selected columns to the user, and same can be done by using

SELECT col1, col2
FROM   xyz

, what is the point of using views?

A: 

A view can be more complicated than just showing certain columns. It is a stored query. Wikipedia has much more detail.

Chris Boyle
+8  A: 
  • Using a view saves you copying and pasting your queries and adds code reusability, so you can change a single view instead of 10 queries in the different places of your code.
  • Different permissions can be granted on views and tables, so that you can show only a portion of data to a user
  • A view can be materialized, which means caching the results of the underlying query
Quassnoi
A: 

refer to this link and u know more about views http://www.sql-server-performance.com/articles/dev/views_in_sql_server_p1.aspx

KuldipMCA
Reusbility is the main concept behind the view and u can use more than one tables in views
KuldipMCA
+1  A: 

Views make SQL easier to write (and read).

You can also use views to control access permissions.

Thilo
+2  A: 

As Quassnoi said, it's useful for granting permission to certain rows in a table.

For example, let's say a lecturer at a university needs access to information on students in her classes. She shouldn't have access to the "students" table because she could look up or modify information for any student in the whole university. The database admin makes a view that only shows students from the lecturers classes and gives the lecturer the appropriate permissions for the view. Now the lecturer has access to her own students' data, but not the whole "students" table.

Tom Dalling