The best SQL CREATE VIEW, REPLACE VIEW, DROP VIEW statement Tutorial In 2024, In this tutorial you can learn SQL CREATE VIEW statement,SQL CREATE VIEW Examples,SQL update view,SQL revocation view,
A view is a visual table.
This chapter explains how to create, update, and delete views.
In SQL, a view is based on the result set of SQL statements visualization table.
View contains rows and columns, just like a real table. The field is the view from one or more databases in real fields in the table.
You can add to the view SQL functions, WHERE and JOIN statements to be present the data as if the data is from a single table the same.
NOTE: The view always show the latest data!Whenever a user queries view, the database engine uses an SQL statement to rebuild the view data.
Northwind sample database has some of the default installation view.
View "Current Product List" lists all products in use (not discontinued product) from the "Products" table. This view is created using the following SQL:
We can query the view above like this:
Another view of the Northwind sample database will select "Products" table, all higher than the average unit price unit price of products:
We can query the view above like this:
Another view of the Northwind sample database will be calculated in 1997. Total sales in each category. View Please note that this view is from another named "Product Sales for 1997" in which selected data:
We can query the view above like this:
We can also add a condition to the query. Now, we just need to see the total number of sales "Beverages" category:
You can use the following syntax to update the view:
Now we want to "Current Product List" view to add "Category" column. We will update the view with the following SQL:
You can delete a view by DROP VIEW command.