RDBMS Lecture Notes Unit4 chapter12 VIEW

muruganjit1 896 views 15 slides Jul 12, 2024
Slide 1
Slide 1 of 15
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15

About This Presentation

Description:
Welcome to the comprehensive guide on Relational Database Management System (RDBMS) concepts, tailored for final year B.Sc. Computer Science students affiliated with Alagappa University. This document covers fundamental principles and advanced topics in RDBMS, offering a structured appr...


Slide Content

RDBMS -Unit IV
Chapter 12
VIEW
Prepared By
Dr. S.Murugan, Associate Professor
Department of Computer Science,
AlagappaGovernment Arts College, Karaikudi.
(Affiliated by AlagappaUniversity)
Mailid: [email protected]
Reference Book:
LEARN ORACLE 8i, JOSE A RAMALHO

VIEW
➢Aviewisavirtualorlogicaltablethatallowstheviewingor
manipulatingofthecontentsofoneormoretablesinawindow.
➢Aviewlookslikeandworkssimilarlytoanormaltable,except
thatitscontentscanbedrawnfromseveraldifferenttablesor
evenotherviews.
➢Thetablescontainingtheorigincolumnsarecalledbasetables.
➢Aview,unlikeatable,hasnophysicalspaceallocatedtoits
data.
➢Itiscreatedbyaquerythatusesoriginorbase tables
from which to extractdata.
➢Thebasetablescanbetablesorviews.

VIEW

ADVANTAGES OF VIEW
➢Theviewcanbecreatedwithspecificcolumnonly.
➢Thesameviewcanbeusedbydifferentusers.
➢Atableforgeneralusecanbedividedintospecific
viewsforcertainusers.
➢TheexecutionoftheSELECTcommandissimplified.
➢Thenamesofcolumnscanbechanged.
➢A view can be referenced in the following SQL
commands: COMMENT, DELETE, INSERT,
LOCK TABLE, UPDATE AND SELECT

Restrictions on Using a View
➢Insert,update,anddeleteoperationscannotbe
performedinaviewformedbycolumnsfrommore
thanonetable.
➢viewscannotmentionthenextvalorcurrvalpseudo
columns.
➢Arowcannotbeinsertedinaviewthathasabase
tablecontainingacolumnwiththeNOTNULL
restriction.

Creating a View
➢The command responsible for creating and modifying views is
CREATE VIEW.
➢REPLACE: Re-creates an existing view
➢FORCE: View created even when the base table does not exist.
➢NOFORCE: If the base table is existthen only the view is
created.
➢WITH READ ONLY:
SpecifiesthattheINSERT,UPDATE,orDELETEcommands
cannotbeexecutedintheview.

A View Based on a Single Table
A view can be created with all the columns of a table by
using *. The NEWDEP View can be created from
DEPARTMENT.

A View Based on a Single Table
Here, DEPARTMENT is a base table and NEWDEP is a
VIEW.

A View Based on Two Tables (Join View)
➢Aviewcanbecreatedbyusingtwotables.The
creationofaviewlinkingtheDEPARTMENT and
LOCATIONtables.Let’sexaminethecontentsofeach
ofthem.

A View Based on Two Tables (Join View)
➢Aviewcanbecreatedbyusingthefollowing
command.
➢Itdisplaystherecordsfrombothtablesthatcontainthesame
valueinthelocation_idfield.
➢Only11recordscorrespondingtothe11rowsofthe
DEPARTMENT tablearedisplayed,alongwiththe
regional_groupfieldoftheLOCATIONtableoftherowwith
samelocation_id.

A View Based on Two Tables (Join View)
➢Theresultofviewcanbedisplayedasfollows.

Using the SELECT Command in a View
A view functions as a normal table for most operations.
The SELECT command also works the same in a view.

Deleting a View
➢Todeletethedefinitionofaviewfromthedata
dictionary,usetheDROPVIEWcommandfollowed
bythenameoftheview.
➢Thiscommanddoesnotaffectthebasetables.
Syntax:
DROPVIEWname_of_view
➢Example:DROPVIEWgendep

Deleting a View
➢Todeletethedefinitionofaviewfromthedata
dictionary,usetheDROPVIEWcommandfollowed
bythenameoftheview.
➢Thiscommanddoesnotaffectthebasetables.
Syntax:
DROPVIEWname_of_view
➢Example:DROPVIEWgendep

Viewing the Definitions of the View
➢The definitions of a view are stored in a view called
USER_VIEWS in the data dictionary. The following
shows the structure of such a view:
➢SQL> describe user_views;
➢To see the name and text of the command that builds
this view, use the view_namecolumn and text:
SQL> select view_name, text from user_views;
VIEW_NAME TEXT
-------------------------------------
EMPBASIC select employee_id,
last_name,first_name,
salary from employee