What is View

A view is just an output of stored query. It does not take disk space since it does not stored data, only for the definition in data dictionary it takes negligible space. View can’t be indexed or have any constraint. View’s stored the query in data dictionary, whenever someone queries a view it gets data from base table using the query. The main purpose of a view is to hide complex query and to restrict access to predetermined set of columns and rows of a table. Regarding performance, to do direct query from database and use view for that purpose will be same. Layering views (One view based on another view) is bad practice or joining view with another table which might decrease performance.

Example:

CREATE VIEW
   view_emp
AS
  SELECT * FROM (select empid,empname from emp) WHERE empid BETWEEN 100 AND 300;

Comments