0% found this document useful (0 votes)
32 views2 pages

What Is A VIEW in Oracle

nice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

What Is A VIEW in Oracle

nice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

What is a VIEW in Oracle?

An Oracle VIEW, in essence, is a virtual table that does not physically exist. Rather, it is created
by a query joining one or more tables.

Create VIEW
Syntax

The syntax for the CREATE VIEW Statement in Oracle/PLSQL is:

CREATE VIEW view_name AS


SELECT columns
FROM tables
[WHERE conditions];
view_name
The name of the Oracle VIEW that you wish to create.
WHERE conditions
Optional. The conditions that must be met for the records to be included in the VIEW.

Example

Here is an example of how to use the Oracle CREATE VIEW:

CREATE VIEW sup_orders AS


SELECT suppliers.supplier_id, orders.quantity, orders.price
FROM suppliers
INNER JOIN orders
ON suppliers.supplier_id = orders.supplier_id
WHERE suppliers.supplier_name = 'Microsoft';

This Oracle CREATE VIEW example would create a virtual table based on the result set of the
SELECT statement. You can now query the Oracle VIEW as follows:

SELECT *
FROM sup_orders;

Update VIEW
You can modify the definition of an Oracle VIEW without dropping it by using the Oracle
CREATE OR REPLACE VIEW Statement.

Syntax

The syntax for the CREATE OR REPLACE VIEW Statement in Oracle/PLSQL is:

CREATE OR REPLACE VIEW view_name AS


SELECT columns
FROM table
WHERE conditions;
view_name
The name of the Oracle VIEW that you wish to create or replace.

Example

Here is an example of how you would use the Oracle CREATE OR REPLACE VIEW
Statement:

CREATE or REPLACE VIEW sup_orders AS


SELECT suppliers.supplier_id, orders.quantity, orders.price
FROM suppliers
INNER JOIN orders
ON suppliers.supplier_id = orders.supplier_id
WHERE suppliers.supplier_name = 'Apple';

This Oracle CREATE OR REPLACE VIEW example would update the definition of the Oracle
VIEW called sup_orders without dropping it. If the Oracle VIEW did not yet exist, the VIEW
would merely be created for the first time.

Drop VIEW
Once an Oracle VIEW has been created, you can drop it with the Oracle DROP VIEW
Statement.

Syntax

The syntax for the DROP VIEW Statement in Oracle/PLSQL is:

DROP VIEW view_name;


view_name
The name of the view that you wish to drop.

Example

Here is an example of how to use the Oracle DROP VIEW Statement:

DROP VIEW sup_orders;

This Oracle DROP VIEW example would drop/delete the Oracle VIEW called sup_orders.

You might also like