Professional Documents
Culture Documents
After
After completing
completing this
this lesson,
lesson, you
you should
should be
be able
able
to
to do
do the
the following:
following:
•• Describe
Describe aa view
view
•• Create,
Create, alter
alter the
the definition
definition of,
of, and
and drop
drop aa view
view
•• Retrieve
Retrieve data
data through
through aa view
view
•• Insert,
Insert, update,
update, and
and delete
delete data
data through
through
aa view
view
•• Create
Create and
and use
use an
an inline
inline view
view
•• Perform
Perform “Top-N”
“Top-N” analysis
analysis
Object Description
•• To
To restrict
restrict data
data access
access
•• To
To make
make complex
complex queries
queries easy
easy
•• To
To provide
provide data
data independence
independence
•• To
To present
present different
different views
views of
of the
the same
same data
data
DESCRIBE
DESCRIBE empvu80
empvu80
SELECT *
FROM salvu50;
Oracle Server
iSQL*Plus
USER_VIEWS
SELECT * EMPVU80
FROM empvu80; SELECT employee_id,
last_name, salary
FROM employees
WHERE department_id=80;
EMPLOYEES
You
You can
can remove
remove aa view
view without
without losing
losing data
data because
because aa
view
view is
is based
based on
on underlying
underlying tables
tables in
in the
the database.
database.
DROP
DROP VIEW
VIEW view;
view;
•• An
An inline
inline view
view is
is aa subquery
subquery with
with an
an alias
alias (or
(or
correlation
correlation name)
name) that
that you
you can
can use
use within
within aa SQL
SQL
statement.
statement.
•• A
A named
named subquery
subquery inin the FROM clause
the FROM clause of
of the
the main
main
query
query isis an
an example
example of of an
an inline
inline view.
view.
•• An
An inline
inline view
view is
is not
not aa schema
schema object.
object.
•• Top-N
Top-N queries
queries ask
ask for
for the
the nn largest
largest or
or smallest
smallest
values
values of
of aa column.
column. For
For example:
example:
–– What
What are
are the
the ten
ten best
best selling
selling products?
products?
–– What
What are
are the
the ten
ten worst
worst selling
selling products?
products?
•• Both
Both largest
largest values
values and
and smallest
smallest values
values sets
sets are
are
considered
considered Top-N
Top-N queries.
queries.
To
To display
display the
the top
top three
three earner
earner names
names and
and salaries
salaries
from
from the EMPLOYEES table:
the EMPLOYEES table:
1 2 3
1 2 3