SQL syntax Advanced Application II: View

Source: Internet
Author: User

SQL CREATE View Statement What is a view?

In SQL, a view is a table of visualizations based on the result set of an SQL statement.

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.

CREATE VIEW view_name asselect column_name (s) from table_namewhere 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 Update View

You can use the following syntax to update the view:

SQL CREATE or replace view syntaxcreate or replace view view_name Asselect column_name (s) from table_namewhere condition

SQL undo View

You can delete a view by using the drop View command.

SQL DROP View Syntaxdrop View view_name

View actual Application

In the EF framework, the use of views is one of the most effective ways to optimize query speed in a detailed list of multi-table federated queries.

There are two ways to create a new view:

One is the creation of an interface visualization, and one that is created using SQL scripts.

Below I share a CREATE view of the general script, for the new small white, can be saved, in case of a rainy future

Use Wot_inventorygoif EXISTS (SELECT 1 from sys.views WHERE Name = ' Invoicesearchlistview ')    DROP VIEW Invoicesearchlis TView; Gocreate View Invoicesearchlistview As--replace the name of the views, write your query here to go

PS: Welcome to scan the QR code below or click on the link, join QQ group

SQL syntax Advanced Application II: 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.