Syntax for creating views in Oracle

Source: Internet
Author: User
Tags dname

The syntax for creating a view in Oracle is very important, because creating a view in Oracle makes it one of the most common operations. Before learning the syntax for creating a view in Oracle, let's take a look at what a view is.

A view is a logical table based on one or more tables or views. It does not contain data and allows you to query and modify the data in the table. A view-based table is called a base table.

A view is a select statement stored in the data dictionary. You can use Oracle to create views to extract logical sets or combinations of data.

Advantages of a view:

1. Access to the database because the view can selectively select a part of the database.

2. You can obtain results from complex queries through simple queries.

3. Maintain data independence and try to retrieve data from multiple tables.

4. Different views can be generated for the same data.

Views are classified into simple views and complex views.

View creation:

 
 
  1. CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view_name   
  2.  
  3. [(alias[, alias]...)]   
  4.  
  5. AS subquery  
  6. [WITH CHECK OPTION [CONSTRAINT constraint]]   
  7. [WITH READ ONLY]   

Where:
Or replace: If the created attempt already exists, ORACLE automatically recreates the view;
FORCE: this view is automatically created no matter whether the base table exists in ORACLE;
NOFORCE: this view is created only when the base table exists in ORACLE:
Alias: the alias defined for the columns generated by the view;
Subquery: a complete SELECT statement that defines aliases;
With check option:
The inserted or modified data rows must meet the view-defined constraints;
With read only:
This view does not support any DML operations.

For example:

 
 
  1. CREATE  OR  REPLACE  VIEW  dept_sum_vw  
  2.    (name,minsal,maxsal,avgsal)  
  3. AS  SELECT d.dname,min(e.sal),max(e.sal),avg(e.sal)  
  4. FROM    emp e,dept d  
  5. WHERE  e.deptno=d.deptno  
  6. GROUP  BY  d.dname; 

Statement for creating a tablespace in oracle

How to Implement Oracle index Reconstruction

Complete Oracle File System Parsing

ORACLE system table and data dictionary View

In-depth analysis of Oracle ERP system module
 
 

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.