1 Chapter 8B Objectives: to learn • to create and use updatable views • to use the advanced SQL JOIN operator syntax Outline • Updatable Views • SQL Join Operators – Recursive Joins & other special join types – ANSI standard syntax • Join Using • Join On – Left & Right Outer Joins 1 Fall 2010- CS275 Updatable Views • Updatable view is a view that can be used to update attributes in the base tables • Updating multiple tables as one transaction. – Oracle Update allows only one table or view on the Update. – A View can create a single transaction for updating more than one table – Create a view with columns to update from each table. – Often done as Batch Update Routines • non-event driven by user • done when system is off-line 2 Fall 2010- CS275 Updatable Views • Not all views are updatable – No GROUP BY expressions or aggregate functions – Cannot use set operators (union, minus, intersect) – Most restrictions are based on use of JOINs • Simple joins are ok. Example: Creating a view of the Product & Sales tables 3 Fall 2010- CS275 Updatable Views • Creating a view of the Product & Sales tables: Create view PSVIEW as (select m.prod_id, m.prod_qoh, s.ps_qty from prodmaster m, prodsales s where m.prod_id = s.prod_id); • To list your view objects Select object_name, object_type from user_objects where object_type in (‘view', ‘table'); 4 Fall 2010- CS275
6
Embed
Chapter 8B Updatable Views · –Oracle Update allows only one table or view on the ... • EquiJoin –Where the join condition uses = • Theta Join ... • Cartesian product of
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
Chapter 8B
Objectives: to learn
• to create and use
updatable views
• to use the advanced
SQL JOIN operator
syntax
Outline
• Updatable Views
• SQL Join Operators– Recursive Joins &
other special join types
– ANSI standard syntax• Join Using
• Join On
– Left & Right Outer
Joins
1Fall 2010- CS275
Updatable Views
• Updatable view is a view that can be used to
update attributes in the base tables
• Updating multiple tables as one transaction.– Oracle Update allows only one table or view on the
Update.
– A View can create a single transaction for updating
more than one table
– Create a view with columns to update from each
table.
– Often done as Batch Update Routines • non-event driven by user
• done when system is off-line
2Fall 2010- CS275
Updatable Views
• Not all views are updatable
– No GROUP BY expressions or aggregate functions
– Cannot use set operators (union, minus, intersect)
– Most restrictions are based on use of JOINs
• Simple joins are ok.
Example: Creating a view of the Product & Sales tables
3
Fall 2010- CS275
Updatable Views
• Creating a view of the Product & Sales tables:
Create view PSVIEW as
(select m.prod_id, m.prod_qoh, s.ps_qty
from prodmaster m, prodsales s
where m.prod_id = s.prod_id);
• To list your view objects
Select object_name, object_type
from user_objects
where object_type in (‘view', ‘table');
4Fall 2010- CS275
2
Updatable Views
• Describe it’s columnsSQL> describe PSView
Name Null? Type----------------------------------------- --------------------PROD_ID NOT NULL VARCHAR2(4)PROD_QOH NUMBER(5,2)PS_QTY NUMBER(5,2)