Common database objects in Oracle-View

Source: Internet
Author: User

Common database objects in Oracle-View
I. view definition: Logical Data Set extracted from the table
A) a view is a virtual table.
B) The view is built on an existing table. The view depends on the created tables, which are called base tables.
C) the statement that provides data content to the view is a SELECT statement, which can be understood as a stored SElECT statement.
D) The view provides users with another representation of the base table data.
Ii. Why use a view?
A) Data Access Control: provides a security mechanism to block data that users should not know when displaying data in a view.
B) Simplified query: The select statement constructs a complex query statement, which must be called each time it is used.
C) avoid repeated access to the same data
3. Create a view:
A) embed a subquery in the create view statement.
I. Create [OR REPLACE] [FORCE | NOFORCE] VIEW [(alias [, alias]…)]
AS subquerytion
[With check option [CONSTRAINT constraint]
[With read only [CONSTRAINT constraint]
B) subqueries can be complex SELECT statements.
I. CREATE VIEW empvu
AS select employee_id, last_name, salary
FROM employees
WHERE department_ed = 80;
C) Description view structure:
I. Describe empvu;
D. Define the column alias in the subquery when creating a view.
I. SQL> create view usersview as select username name, password pass from users;
Ii. // query view
SQL> select * from usersview;
E) Use the create or replace view clause to modify the VIEW
I. SQL> create or replace view usersview as (select * from users );
F) Create a view with a function and a groupby clause
I. SQL> create or replace view gde as (select deptno, count (*) cou from emp group by deptno );
G) create a connection view with the order by clause of the group by clause
I. SQL> create view gdeo as select e. deptno, count (*) cou from emp e inner join dept d on e. deptno = d. deptno group by e. deptno order by e. deptno;
Iv. delete a view
Drop view name;


From song lixing's column

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.