Oracle Data Objects: use of views

Source: Internet
Author: User
Tags dname one table

1. Why Use views

(1) Restricting access to data: Users can only see part of the information in the base table.

(2) Making complex queries easy: The data in the view may come from multiple tables.

(3) Make the data relatively independent: from the perspective of project development, the module corresponding to the view, the module contains more than one table, the module changes only to modify the corresponding view, the corresponding table structure without modification.

(4) representing different perspectives on the same data: employees from different departments can only see the information in the department.

2. Create a View

CREATE VIEW Empvu10

As SELECT empno, ename, Job

From EMP1

WHERE deptno=30

/(The ORDER BY clause cannot be used in queries that define views)

3. Query view

The SELECT statement for the view definition is saved in the Long text field.

Use set long 150 to increase the LONG maximum display width, default to 80

SELECT * FROM User_views

/

Syntax description

CREATE [OR REPLACE] [force| Noforce] View View

[(alias[, alias] ...)]

As subquery

[With CHECK OPTION [CONSTRAINT CONSTRAINT]]

[with READ only];

Or REPLACE If the view already exists, it is equivalent to modifying the view

FORCE | [Noforce] Create a view regardless of whether the base table exists [only base table existence can be created]

With CHECK OPTION the INSERT and update operations performed through the view cannot create rows of data that are not retrieved by the view

With READ only disables DML operations on the view

4. Create a complex view

You cannot modify the data of a base table by modifying the view

CREATE VIEW Dept_sum_vu

(dname,minsal,maxsal,avgsal)

As SELECT d.dname,min (e.sal),

MAX (SAL), AVG (SAL)

From EMP e,dept D

WHERE E.deptno=d.deptno

GROUP by D.dname

/

Data comes from multiple tables, using grouping functions in queries

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.