Sql view - sql - sql tutorial - learn sql
Definition of view
- In SQL, a view is a virtual table based on the result-set of an SQL statement.
- A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.
- In database theory, a View is the result set of a stored query on the data, which the database users can query just as they would in a persistent database collection object.
- This pre-established query command is kept in the database dictionary.
- As a result set, it is a virtual table computed or collated dynamically from data in the database when access to that view is requested.
- A view is a virtual table and it consists of rows and columns just like a table. The difference between a view and a table is that views are definitions built on top of other tables (or views), and do not hold data themselves.
- If data is changing in the underlying table, the same change is reflected in the view.
The Syntax to create a sql view is:
- view_name is the name of the VIEW.
- The SELECT statement is used to define the columns and rows that you want to display in the view.
sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorialFor Example: to create a view on the product table the sql query would be like
For Example: to create a view on the product table the sql query would be like
Views offer the following advantages:
- Ease of use: A view hides the complexity of the database tables from end users. Essentially we can think of views as a layer of abstraction on top of the database tables.
- Space savings: Views takes very little space to store, since they do not store actual data.
- Additional data security: Views can include only certain columns in the table so that only the non-sensitive columns are included and exposed to the end user. In addition, some databases allow views to have different security settings, thus hiding sensitive data from prying eyes.