Monday, February 19, 2024

SQL Server View

In SQL Server, a view is a virtual table that is based on the result of a SELECT query. It does not store data itself but rather represents a compiled SELECT query that can be referenced and used in other queries.

Facts about views

  1. A view is a database object based on compiled query created using one or more tables.
  2. A view is a virtual table because it references a table. A view can reference a table which is created by joining multiple tables.
  3. View does not occupy physical space unless it is a materialized view. It means that view contains the query definition for result set not the data of result set.

Why is view created?


View is created as interface to provide only that data to user that we want to display as per the permissions of the user. It is a kind of window to view specific columns or/and rows from table.

View provides a layer of abstraction over tables. Due to abstraction of views, users do not know about the underlying tables.

View provides security of data because of its layer of abstraction over table.

View allows us to simplify complex queries because view can be used in other queries.

View can be queried like tables and it therefore acts as data source. So it allows code reusability.

No comments:

Post a Comment

Hot Topics