0% found this document useful (0 votes)
23 views2 pages

Views PDF

The objective of the exercise was to create and manipulate database objects using views in Oracle 11g. The procedures involved creating views on tables to selectively display columns and rows for different purposes like security. Advantages of views include additional security, simplifying data access and presentation. Types of views are horizontal (using WHERE clause) and vertical (selecting specific columns). Examples demonstrated creating views on an EMP table to show only ASP employees or selected columns, executing DML on views, and dropping a view. The result was that various database objects were successfully manipulated using views.

Uploaded by

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

Views PDF

The objective of the exercise was to create and manipulate database objects using views in Oracle 11g. The procedures involved creating views on tables to selectively display columns and rows for different purposes like security. Advantages of views include additional security, simplifying data access and presentation. Types of views are horizontal (using WHERE clause) and vertical (selecting specific columns). Examples demonstrated creating views on an EMP table to show only ASP employees or selected columns, executing DML on views, and dropping a view. The result was that various database objects were successfully manipulated using views.

Uploaded by

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

Exercise Number: 6

Title of the Exercise : VIEWS


Date of the Exercise :

OBJECTIVE (AIM) OF THE EXPERIMENT


To create and manipulate various database objects of the Table using views
FACILITIES REQUIRED AND PROCEDURE
a) Facilities required to do the experiment:
Sl.No. Facilities Quantity
required
1 System 1
2 Operating System Windows
3 Front end
4 Back end Oracle11g
b) Procedure for doing the experiment:
Step
Details of the step
no.
Views:
A view is the tailored presentation of data contained in one or more table and can
1 also be said as restricted view to the data’s in the tables. A view is a “virtual table” or
a “stored query” which takes the output of a query and treats it as a table. The table
upon which a view is created is called as base table.
A view is a logical table based on a table or another view. A view contains no data of
its own but is like a window through which data from tables can be viewed or
2
changed. The tables on which a view is based are called base tables. The view is
stored as a SELECT statement in the data dictionary
Advantages of a view:
a. Additional level of table security.
3 b. Hides data complexity.
c. Simplifies the usage by combining multiple tables into a single table.
d. Provides data’s in different perspective.
Types of view:
4 Horizontal -> enforced by where cause
Vertical -> enforced by selecting the required columns
c) SQL Commands
Creating and dropping view:
Syntax:
Create [or replace] view <view name> [column alias names] as <query> [with
<options> conditions];
Drop view <view name>;
Example:
Create or replace view empview as select * from emp;
Drop view empview;
d) Queries:
Tables used:
SQL> select * from emp;
EMPNO ENAME JOB DEPTNO SAL
---------- -------------------- ---------- ---------- ---------
- 1 Mathi AP 1 10000 2
Arjun ASP 2 12000
3 Gugan ASP 2 20000
4 Karthik AP 1 15000

Q1: The organization wants to display only the details of the employees those who are
ASP. (Horizontal portioning) Solution:
1. Create a view on emp table named managers 2.
Use select from clause to do horizontal partioning
Ans:
SQL> create view empview as select * from emp where job='ASP';
View created.
SQL> select * from empview;
EMPNO ENAME JOB DEPTNO SAL
---------- -------------------- ---------- ---------- ----------
2 Arjun ASP 2 12000
3 Gugan ASP 2 20000
Q2: The organization wants to display only the details like empno, empname,
deptno, deptname of the employees. (Vertical portioning) Solution:
1. Create a view on emp table named general 2. Use select from clause to do vertical partioning
Ans:
SQL> create view empview1 as select ename,sal from emp;
View created.
Q3: Display all the views generated.
Ans:
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
EMPVIEW VIEW
EMPVIEW1 VIEW
Q4: Execute the DML commands on the view created.
Ans:
SQL> select * from empview;
EMPNO ENAME JOB DEPTNO SAL
---------- -------------------- ---------- ---------- ----------
2 Arjun ASP 2 12000
3 Gugan ASP 2 20000
Q5: Drop a view.
Ans: SQL> drop view empview1;
View dropped.
e) Result:
Thus the creation and manipulate various database objects of the Table using views was
successfully executed.

You might also like