What is a view? )
1. A view is a database object, a virtual table that is exported from one or more data tables or views, and the data corresponding to the view is not really stored in the view, but is stored in the referenced data table, and the structure and data of the view are the results of querying the data table. 2. Depending on the criteria given when creating the view, the view can be part of a data table or a union of multiple base tables, which stores the definition of the query statement to be retrieved for use when referencing the view.
Two. Why (how do I use views?) Advantages of the view)
1. Simplify data manipulation: Views Simplify how users work with data. 2. Focus on specific data: unnecessary data or sensitive data can not be present in the view. 3. The view provides a simple and effective security mechanism that allows you to customize the access rights of different users to the data. 4. Provide backward compatibility: Views enable users to create backward-compatible interfaces for tables when the schema of a table changes. 5. Custom data: Views allow users to view data in different ways. 6. Exporting and importing data: You can use views to export data to other applications. Three. How (view creation syntax, delete, demo)
create [or Replace [force| Noforce view View_ Name [ (alias[, Alias]< Span style= "color: #000000;" >...)] as subquery [with CHECK OPTION [CONSTRAINT constraint][with READ only
REPLACE : Oracle automatically rebuilds the view if the created attempt already exists; Force : The view is automatically created by Oracle regardless of the existence of the base table; Noforce : Only the base table exists for Oracle to create the view: Alias: Aliases defined for the columns generated by the view; subquery : A complete SELECT statement in which the alias can be defined;CHECK OPTION : The data rows that are inserted or modified must satisfy the constraints of the view definition; only: No DML operations can be performed on the view.
CREATE OR REPLACE VIEW SELECT d.dname,min (e.sal),Max (e.sal), AvgfromWHERE e.deptno=
--Create a view for user authorization--Grant create all view to ZDGSHR; Users who can create views for all databasesGrantCreateViewToZDGSHR;--Create a simple viewCreateViewTempAsSelect*FromZd_member_basic_info;--TestSelect*FromTempwhere rownum=1;--Create a simple view: Read-onlyCreateOrReplaceview Temp1as select id,job_number,name,dept_id from Zd_member_ Basic_info with read ; -- test insert into Temp1 ( id,job_number,name,dept_id) values ( 1,0, '
Delete of view:
drop View view_name statement to delete views. Deleting a view's definition does not affect the data in the base table. Only the view owner and the user with the Drop view permission can delete the view. After the view is deleted, other views or apps that are based on the deleted view will be invalid.
The views are divided into simple views and complex views.
Simple views get data from only one table, and complex views get data from multiple tables.
A simple view does not contain functions and data groups, and complex views contain functions and data groups.
A simple view implements DML operations, and complex views are not.
create or replace view Temp1as select distinct name,job_number,dept_id from Zd_member_basic_info with read only; Delete from zd_member_basic_info where Name= '
by name;
Ext.: http://www.cnblogs.com/wean/archive/2012/05/15/2501995.html
ORACLE Create and use views