SQL getting started Tutorial: SQL CREATE VIEW

Source: Internet
Author: User

SQL getting started Tutorial: SQL CREATE VIEW

One opinion is that it is a view.

SQL statement during creation
In SQL, there is a suggestion that a statement is a virtual result set statement based on the table.

There is an opinion that contains rows and columns, just like a real table. The viewpoint of this field, field, from one or more real tables in the database.

You can add SQL functions, where, and add declarations, In order to and present data if the data is from a single table.

SQL CREATE VIEW syntax

Create view view_name
SELECT column_name (s)
FROM table_name
WHERE condition
Let's take a look at an instance of create view.
If you have the Northwind database, you can see that it has several ideas for default installation. The "current product list" lists all active products (products do not stop) from the "Products" table. The idea is to establish the following SQL: CREATE VIEW [Current Product List]
SELECT ProductID, ProductName
FROM Products
WHERE Discontinued = No we can query the above points as follows: SELECT * FROM [Current Product List] Another view is that the unit price for selecting the "Product" table for each Product in the Northwind sample database is higher than the average unit price: create view [Products Above Average Price]
SELECT ProductName, UnitPrice
FROM Products
WHERE UnitPrice> (select avg (UnitPrice) FROM Products) query is. SELECT * FROM [Products Above Average Price] SQL Dropping a View you can delete, With a VIEW View command down. In VIEW of the dropped SQL syntax DROP VIEW view_name

Related Article

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.