• +1-617-874-1011 (US)
  • +44-117-230-1145 (UK)
Live Chat
Follow Us:

CREATE VIEW Statement in SQL

SQL Views

In SQL, a view is a virtual table dependent on the outcome set of a SQL articulation.

A view contains lines and sections, much the same as a genuine table. The fields in a view are fields from at least one genuine table in the database.

You can include SQL capacities, WHERE, and JOIN proclamations to a view and present the information as though the information were originating from one single table.

Make VIEW Syntax
Make VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;

Note: A view dependably appears at date information! The database motor reproduces the information, utilizing the view's SQL explanation, each time a client questions a view.

SQL CREATE VIEW Examples

The accompanying SQL makes a view that demonstrates all clients from Brazil:

Model
Make VIEW [Brazil Customers] AS
SELECT CustomerName, ContactName
FROM Customers
WHERE Country = "Brazil";

We can question the view above as pursues:

Model

SELECT * FROM [Brazil Customers];

The accompanying SQL makes a view that chooses each item in the "Items" table with a cost higher than the normal cost: Model

Make VIEW [Products Above Average Price] AS

SELECT ProductName, Price
FROM Products
WHERE Price > (SELECT AVG(Price) FROM Products);

We can inquiry the view above as pursues:

Model

SELECT * FROM [Products Above Average Price];

SQL Updating a View

A view can be refreshed with the CREATE OR REPLACE VIEW direction.

SQL CREATE OR REPLACE VIEW Syntax

Make OR REPLACE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;

The accompanying SQL includes the "City" segment to the "Brazil Customers" see:

Model

Make OR REPLACE VIEW [Brazil Customers] AS
SELECT CustomerName, ContactName, City
FROM Customers
WHERE Country = "Brazil";
SQL Dropping a View
A view is erased with the DROP VIEW direction.
SQL DROP VIEW Syntax
DROP VIEW view_name;

The accompanying SQL drops the "Brazil Customers" see:

Model

DROP VIEW [Brazil Customers];
Keywords: MYSQL Tutorials, Data Relations homework help, SQL homework help, SQL project Help, Oracle Homework Help, XML homework help, XML and Relational Algebra assignment help, SQL Queries and Updates homework assignment help, XML Queries and Transformations tutoring help, Relational Database Design concept, Higher-Level Design help in UML and ERD, Data Warehousing and Data Mining, help with SQL 2008 database, support for Database help, Microsoft access and mysql database programmer, database development and xml database support, homework helper for asp database and uml modeling, uml sequence diagram and uml class diagram, database design development and software SQL server 2008.