Can We Update Views In Oracle ?
Oracle / PLSQL: VIEW
This Oracle tutorial explains how to create, update, and drop Oracle VIEWS with syntax and examples.
What is a VIEW in Oracle?
An Oracle VIEW, in essence, is a virtual tabular array that does not physically exist. Rather, it is created past 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 weather
- Optional. The conditions that must be met for the records to be included in the VIEW.
Case
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 Bring together orders ON suppliers.supplier_id = orders.supplier_id WHERE suppliers.supplier_name = 'Microsoft';
This Oracle CREATE VIEW case would create a virtual table based on the event ready of the SELECT statement. You tin at present query the Oracle VIEW as follows:
SELECT * FROM sup_orders;
Update VIEW
You can alter the definition of an Oracle VIEW without dropping information technology by using the Oracle CREATE OR Supplant VIEW Statement.
Syntax
The syntax for the CREATE OR REPLACE VIEW Argument in Oracle/PLSQL is:
CREATE OR REPLACE VIEW view_name Equally SELECT columns FROM table WHERE conditions;
- view_name
- The name of the Oracle VIEW that yous wish to create or replace.
Instance
Here is an case of how yous would use the Oracle CREATE OR REPLACE VIEW Statement:
CREATE or Supercede VIEW sup_orders Every bit SELECT suppliers.supplier_id, orders.quantity, orders.cost FROM suppliers INNER Bring together orders ON suppliers.supplier_id = orders.supplier_id WHERE suppliers.supplier_name = 'Apple tree';
This Oracle CREATE OR Supercede 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 commencement time.
Drop VIEW
Once an Oracle VIEW has been created, you tin 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 drib.
Example
Here is an instance of how to use the Oracle Drop VIEW Argument:
Driblet VIEW sup_orders;
This Oracle DROP VIEW example would drop/delete the Oracle VIEW called sup_orders.
Oftentimes Asked Questions
Question: Can you update the information in an Oracle VIEW?
Reply: A VIEW in Oracle is created by joining one or more tables. When yous update record(s) in a VIEW, it updates the records in the underlying tables that make upwardly the View.
Then, yes, y'all tin can update the data in an Oracle VIEW providing you take the proper privileges to the underlying Oracle tables.
Question: Does the Oracle View exist if the table is dropped from the database?
Respond: Yeah, in Oracle, the VIEW continues to exist even after one of the tables (that the Oracle VIEW is based on) is dropped from the database. However, if you effort to query the Oracle VIEW subsequently the table has been dropped, you will receive a message indicating that the Oracle VIEW has errors.
If you recreate the table (the table that you had dropped), the Oracle VIEW will again be fine.
Source: https://www.techonthenet.com/oracle/views.php
Posted by: moralesgagainfoute.blogspot.com
0 Response to "Can We Update Views In Oracle ?"
Post a Comment