What is a view?

A view is nothing but a window of an existing table by which one can view and can also change the values in tables. The main point aspect of view is views have no storage space. For this reason views are also called as virtual tables. Thus in other words a view is a database object that gives a logical representation of one or more database tables.


As we have seen above views have no data for themselves and they represent values from the exiting table. So one have a query why should one have a view concept when there is already a table existing. There are several reasons for the usage of views. But below are some of the reasons listed namely:


Protection of Data:

There may be instance in which a person may like to present only certain data to particular group of employees from a table. In this case the person can create a view from the table having only the needed columns and can make the group of employees have access only to the view created and they by protect the table from unauthorized access.


Ease of Usage:

Sometimes presenting only certain columns or data from a complex table would ease the maintenance and presentation of data.



The general format for creating a view is given below:



CREATE VIEW viewname AS QUERY;



For example if there is a table named as exforsys having columns as empno, ename, sex, salary, depno and if one wishes to create a view named as e1 having columns namely empno, ename, salary having depno=1000. It is done as follows:



CREATE VIEW e1 AS SELECT empno, ename, salary FROM exforsys WHERE depno=1000;



One of the important things is if the base table is deleted and if one refers to the view then it would obviously result in an error.

Questions by GeekAdmin   answers by GeekAdmin

Showing Answers 1 - 6 of 6 Answers

A view acts like a mirror of the main table created. any changes made in the base table are seen in the view while changes made in the view cannot be seen in the base table except if the view is on a single base table.

A view is dropped, it does not effect the base table but if the base table is dropped the view is also dropped.

  Was this answer useful?  Yes

aardvax

  • May 17th, 2007
 

please clarify
that if there are some changes made in view(created from a single  base table)would they reflect in the base table as well?

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions