0% found this document useful (0 votes)
39 views4 pages

Views

A view is a logical representation of a table that has no storage of its own. It acts like a virtual table that is defined by a query. Views can be used to simplify commands, hide complexity, and provide additional security by restricting access to rows and columns. There are different types of views including simple views from one table or complex views from multiple tables. Views also have certain restrictions on allowed DML operations depending on if they include functions, expressions, or not null columns.

Uploaded by

siva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

Views

A view is a logical representation of a table that has no storage of its own. It acts like a virtual table that is defined by a query. Views can be used to simplify commands, hide complexity, and provide additional security by restricting access to rows and columns. There are different types of views including simple views from one table or complex views from multiple tables. Views also have certain restrictions on allowed DML operations depending on if they include functions, expressions, or not null columns.

Uploaded by

siva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

VIEWS

A view is a database object that is a logical representation of a table. It is


delivered from a table but has no storage of its own and often may be used in the
same manner as a table.

A view takes the output of the query and treats it as a table, therefore a view can
be thought of as a stored query or a virtual table.

TYPES
1 Simple view
2 Complex view

Simple view can be created from one table where as complex view can be created
from multiple tables.

WHY VIEWS?

1 Provides additional level of security by restricting access to a


predetermined set of rows and/or columns of a table.
2 Hide the data complexity.
3 Simplify commands for the user.

VIEWS WITHOUT DML


1 Read only view
2 View with group by
3 View with aggregate functions
4 View with rownum
5 Partition view
6 View with distinct

Ex:
SQL> Create view dept_v as select *from dept with read only;
SQL> Create view dept_v as select deptno, sum(sal) t_sal from emp group by
deptno;
SQL> Create view stud as select rownum no, name, marks from student;
SQL> Create view student as select *from student1 union select *from
student2;
SQL> Create view stud as select distinct no,name from student;

VIEWS WITH DML

1 View with not null column -- insert with out not null column not possible
-- update not null column to null is not possible
-- delete possible
2 View with out not null column which was in base table -- insert not possible
-- update, delete possible
3 View with expression -- insert , update not possible
-- delete possible
4 View with functions (except aggregate) -- insert, update not possible
-- delete possible
5 View was created but the underlying table was dropped then we will get
the message like “ view has errors ”.
6 View was created but the base table has been altered but still the view was
with the initial definition, we have to replace the view to affect the
changes.
7 Complex view (view with more than one table) -- insert not possible
-- update, delete possible (not
always)

CREATING VIEW WITHOUT HAVING THE BASE TABLE

SQL> Create force view stud as select *From student;


-- Once the base table was created then the view is validated.

VIEW WITH CHECK OPTION CONSTRAINT

SQL> Create view stud as select *from student where marks = 500 with check
option
constraint Ck;
- Insert possible with marks value as 500
- Update possible excluding marks column
- Delete possible
DROPPING VIEWS

SQL> drop view dept_v;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy