Basic concepts and creation of Oracle views

Source: Internet
Author: User

In Oracle databases, we often use views to create tables, saving time and convenience. Next we will briefly introduce the basic concepts of the view and the creation of the Oracle view.

View Concept

A view is a logical table based on one or more tables or another view. Unlike tables, a view does not contain any data. A table is an entity that exists independently. It is the basic structure used to store data. The view is just a definition that corresponds to a query statement. View data comes from some tables, which are called base tables. You can view a table in a view, as if you are observing one or more tables from different perspectives.
View has the following advantages:
* Data access security can be improved. A view can only access specific parts of a table in the database, which limits the user's access to all rows and columns of the table.
* Simplifies data query and hides the complexity of query. The view data comes from a complex query, but the user's query of the view is very simple.
* A view can retrieve data from multiple tables. Therefore, you can access multiple tables by accessing one view.
* Views are different representations of the same data. By creating different views for the same table for different users, users can access different parts of the same table separately.
A view can be used anywhere in a table, but it has some limitations over operations on the view, especially insert and modify operations. Operations on the view are passed to the base table. Therefore, the constraints and triggers defined on the table work in the view as well.

Create an Oracle View

The creae view system permission is required to create an Oracle VIEW. The VIEW creation syntax is as follows:
CREATE [or replace] [FORCE | NOFORCE] VIEW name [(alias 1 [, alias 2...])]
AS subquery
[With check option [CONSTRAINT name]
[With read only]
Where:
Or replace indicates replacing an existing view.
FORCE: Creates a view regardless of whether the base table exists.
NOFORCE indicates that a view is created only when the base table exists. It is the default value.
The alias is the new name defined for the selected columns in the subquery. It replaces the original column names in the query table.
A subquery is a SELECT query statement used to define a view. It can contain connections, groups, and subqueries.
With check option indicates that the view insertion or modification must meet the constraints of the subquery. The constraint name is the name of the constraint.
With read only indicates that the view is READ-ONLY.
The syntax for deleting a view is as follows:
Drop view name;
To delete a VIEW, you must be the creator of the VIEW or have the permission to drop any view. Deleting a view does not affect the base table or data loss.

  1. Code required to modify the Oracle Stored Procedure
  2. Summary of Oracle stored procedures
  3. Code for implementing the Oracle Stored Procedure
  4. In-depth high-performance dynamic Oracle SQL Development
  5. Analysis of Oracle SQL optimization rules

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.