SQL View (view)

Source: Internet
Author: User

Briefly:

The view contains rows and columns, just like a real table.

A field in a view is a field from a real table in one or more databases.

We can add SQL functions, WHERE, and JOIN statements to the view, and we can also submit the data as if they came from a single table.

Note: The design and structure of a database is not affected by functions, where, or join statements in the view.

Detailed

A view is a virtual table whose contents are defined by a query. As with a real table, a view contains a series of column and row data with names. However, the view does not exist in the database as a stored set of data values. Row and column data is derived from the table referenced by the query that defines the view, and is generated dynamically when the view is referenced. The view acts like a filter for the underlying table referenced in it. A filter that defines a view can come from one or more tables, or other views, of the current or other data base. Distributed queries can also be used to define views that use multiple heterogeneous source data.

A view is a SQL statement of queries stored in a database, and it is mainly for two reasons: security reasons, the view can hide some data, such as: Social Insurance Fund table, you can use the view only display name, address, and do not show social security number and wages, etc., another reason is to make complex queries easy to understand and use.

View: How you view a graphic or document.

Once the view is defined, it is stored in the database, and the data corresponding to it is not stored in the database as a table, and the data seen through the view is only the data stored in the base table. You can query, modify (with some restrictions), delete, as you do with a table.

When you make changes to the data that you see through the view, the data for the underlying table changes, and the changes can be automatically reflected in the view if the data for the underlying table changes.

the role of the view:

* Simple Nature

What you see is what you need. Views not only simplify the user's understanding of the data, they can also simplify their operations. Those queries that are used frequently can be defined as views, so that users do not have to specify all the conditions for subsequent operations at a time.

* Security

Users can only query and modify the data they see through the view. Other data in the database is neither visible nor can be taken. The database Authorization command enables each user to limit the retrieval of a database to a specific database object, but not to a specific row or column on a database. With views, users can be limited to different subsets of data: permissions can be restricted to a subset of another view, or on a subset of the merged views and base tables.

* Logical Data Independence

Views help users to mask the impact of changes in the real-world table structure.

View Syntax:

CREATE VIEW view_name as SELECT column_name (s) from table_name WHERE condition

Note: Views always display the most recent data. Each time a user queries the view, the database engine rebuilds the data by using SQL statements.

SQL View (view)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.