What is View?  


A simple view can be thought of as a subset of a table.

A simple view can be thought of as a subset of a table. 
It can be used for retrieving data, as well as updating or deleting rows. 
Rows updated or deleted in the view are updated or deleted in the table the view was created with.
 It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table.
 The results of using a view are not permanently stored in the database.
 The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.


Comments

Author: satyajee srivastava18 Dec 2010 Member Level: Silver   Points : 1

A view displays one or more database records on the same page. A view can display some or all of the database fields. Views have filters to determine which records they show. Views can be sorted to control the record order and grouped to display records in related sets. Views have other options such as totals and subtotals.

Author: banu21 Dec 2010 Member Level: Gold   Points : 1

view is a virtual table.it contains columns of one or more table.
view serves as a security mechanism.
Users cannot see or access the all data from table.only restircted data can be viewed and modified

Author: satish 21 Dec 2010 Member Level: Gold   Points : 1

View in SQL Server is a Virtual table that consists of columns from one or more tables. It is some what similar to a table, but it(views) is stored in the database. It is a query which is stored as a object. Hence, a view is a object that derives its data from one or more tables. These tables are referred to as base or underlying tables.

Once you have defined a view, you can reference it like any other table in a database.

1. A view serves as a security mechanism.
2.This ensures that users are able to retrieve and modify only the data seen by them.
3. Users cannot see or access the remaining data in the underlying tables.
4. A view also serves as a mechanism to simplify query execution.
5. Complex queries can be stored in the form as a view, and data from the view can be extracted using simple queries.

Author: niraj sharma27 Dec 2010 Member Level: Silver   Points : 1

SQL CREATE VIEW Statement



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

A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.

You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from one single table.

SQL CREATE VIEW Syntax


CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition



SQL CREATE VIEW Examples

If you have the Northwind database you can see that it has several views installed by default.

The view "Current Product List" lists all active products (products that are not discontinued) from the "Products" table. The view is created with the following SQL:

CREATE VIEW [Current Product List] AS
SELECT ProductID,ProductName
FROM Products
WHERE Discontinued=No
We can query the view above as follows:

SELECT * FROM [Current Product List]
Another view in the Northwind sample database selects every product in the "Products" table with a unit price higher than the average unit price:

CREATE VIEW [Products Above Average Price] AS
SELECT ProductName,UnitPrice
FROM Products
WHERE UnitPrice>(SELECT AVG(UnitPrice) FROM Products)
We can query the view above as follows:

SELECT * FROM [Products Above Average Price]
Another view in the Northwind database calculates the total sale for each category in 1997. Note that this view selects its data from another view called "Product Sales for 1997":

CREATE VIEW [Category Sales For 1997] AS
SELECT DISTINCT CategoryName,Sum(ProductSales) AS CategorySales
FROM [Product Sales for 1997]
GROUP BY CategoryName
We can query the view above as follows:

SELECT * FROM [Category Sales For 1997]
We can also add a condition to the query. Now we want to see the total sale only for the category "Beverages":

SELECT * FROM [Category Sales For 1997]
WHERE CategoryName='Beverages'

SQL Updating a View

You can update a view by using the following syntax:

SQL CREATE OR REPLACE VIEW Syntax

CREATE OR REPLACE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
Now we want to add the "Category" column to the "Current Product List" view. We will update the view with the following SQL:

CREATE VIEW [Current Product List] AS
SELECT ProductID,ProductName,Category
FROM Products
WHERE Discontinued=No

SQL Dropping a View

You can delete a view with the DROP VIEW command.

SQL DROP VIEW Syntax

DROP VIEW view_name

Author: manisha20 Jan 2011 Member Level: Gold   Points : 1

View is a virtual table and contains rows & columns just like real table.The fields in a view are fields from one or more real tables in the database.

Syntax to create View:
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition

Syntax to drop view:
DROP VIEW view_name

Author: Er. Ram Singh21 Feb 2011 Member Level: Gold   Points : 1

View in SQL Server is a Virtual table that consists of columns from one or more tables. It is some what similar to a table, but it(views) is stored in the database. It is a query which is stored as a object. Hence, a view is a object that derives its data from one or more tables. These tables are referred to as base or underlying tables.

Once you have defined a view, you can reference it like any other table in a database.

1. A view serves as a security mechanism.
2.This ensures that users are able to retrieve and modify only the data seen by them.
3. Users cannot see or access the remaining data in the underlying tables.
4. A view also serves as a mechanism to simplify query execution.
5. Complex queries can be stored in the form as a view, and data from the view can be extracted using simple queries.


The view "Current Product List" lists all active products (products that are not discontinued) from the "Products" table. The view is created with the following SQL:

CREATE VIEW [Current Product List] AS
SELECT ProductID,ProductName
FROM Products
WHERE Discontinued=No
We can query the view above as follows:

SELECT * FROM [Current Product List]
Another view in the Northwind sample database selects every product in the "Products" table with a unit price higher than the average unit price:

CREATE VIEW [Products Above Average Price] AS
SELECT ProductName,UnitPrice
FROM Products
WHERE UnitPrice>(SELECT AVG(UnitPrice) FROM Products)
We can query the view above as follows:

SELECT * FROM [Products Above Average Price]
Another view in the Northwind database calculates the total sale for each category in 1997. Note that this view selects its data from another view called "Product Sales for 1997":

CREATE VIEW [Category Sales For 1997] AS
SELECT DISTINCT CategoryName,Sum(ProductSales) AS CategorySales
FROM [Product Sales for 1997]
GROUP BY CategoryName
We can query the view above as follows:

SELECT * FROM [Category Sales For 1997]
We can also add a condition to the query. Now we want to see the total sale only for the category "Beverages":

SELECT * FROM [Category Sales For 1997]
WHERE CategoryName='Beverages'

SQL Updating a View

You can update a view by using the following syntax:

SQL CREATE OR REPLACE VIEW Syntax

CREATE OR REPLACE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
Now we want to add the "Category" column to the "Current Product List" view. We will update the view with the following SQL:

CREATE VIEW [Current Product List] AS
SELECT ProductID,ProductName,Category
FROM Products
WHERE Discontinued=No

SQL Dropping a View

You can delete a view with the DROP VIEW command.

SQL DROP VIEW Syntax

DROP VIEW view_name

Author: vijay11 Mar 2011 Member Level: Silver   Points : 1

view are derived from one or more tables based on our requirement.
views are updatable, means if we can change any modifications on view that change reflect on parent table.

regards
Vijay J

Author: Kuldeep Kumar25 Jun 2011 Member Level: Bronze   Points : 1

ViewState is typically used to store temporary state specific to an individual page in ASP.NET. It is round-tripped to the server in a hidden form field.

Author: Ultimaterengan04 Jul 2011 Member Level: Gold   Points : 1

This is copied resource.


http://www.techiebird.com/DBInterview1.html

check Explain about View? question.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: