Geeks Talk

Prepare for your Next Interview




Updating a View

This is a discussion on Updating a View within the SQL forums, part of the Databases category; We Create a view by using 2 tables for( ex.emp table and dept table) after that i changed some rows in the emp table what will happen in the ...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 01-25-2008
Junior Member
 
Join Date: Jan 2008
Location: Chennai
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
amitkannan is on a distinguished road
Updating a View

We Create a view by using 2 tables for( ex.emp table and dept table) after that i changed some rows in the emp table what will happen in the view? whether the view also gets updated or not?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-25-2008
Contributing Member
 
Join Date: Apr 2006
Location: kolkata(now in noida)
Posts: 56
Thanks: 9
Thanked 3 Times in 2 Posts
bhaski is on a distinguished road
Re: Updating a View

I prepared this document from oracle documentation think may help u--

a view cannot be modified by update, insert, or delete statements if the view query contains any
of the following constructs:
1.a set operator
2.a distinct operator
3.an aggregate or analytic function
4.a group by, order by, model, connect by, or start with clause
5.a collection expression in a select list
6.a subquery in a select list
7.a subquery designated with read only
8.joins, with some exceptions as ---

general rule--> any insert, update, or delete operation on a join view can modify only one underlying
base table at a time.

Update rule --> all updatable columns of a join view must map to columns of a key-preserved table.
If the view is defined with the with check option clause, then all join columns and all columns of repeated tables are not updatable.

Delete rule--> rows from a join view can be deleted as long as there is exactly one key-preserved table
in the join. The key preserved table can be repeated in the from clause. If the view is defined with the with check option clause and the key preserved table is repeated, then the rows cannot be deleted from the view.

Insert rule--> an insert statement must not explicitly or implicitly refer to the columns of a non-key-preserved table. If the join view is defined with the with check option clause, insert statements are not permitted.

Now question is what is key preserved table

a table is said to be key preserved if every key of the table is a key of the join of the table

Last edited by bhaski : 01-25-2008 at 05:38 AM.
Reply With Quote
The Following 2 Users Say Thank You to bhaski For This Useful Post:
  #3 (permalink)  
Old 01-25-2008
Junior Member
 
Join Date: Jan 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
raj_imr2000 is on a distinguished road
Re: Updating a View

Hi Amit,

After creating the view if you are changing data into tables then the view will also gets updated.

Thanks
Raj
Reply With Quote
  #4 (permalink)  
Old 01-25-2008
Expert Member
 
Join Date: Apr 2007
Posts: 404
Thanks: 13
Thanked 52 Times in 52 Posts
susarlasireesha is on a distinguished road
Re: Updating a View

suppose u create a view using empno,name,sal,dept.deptno,dept.loc from emp,dept tables using joining condition( i.e emp.deptno=dept.deptno )when
u insert details in emp table , view will be updated if the deptno is already in dept table if deptno not in dept table then view will not be updated.
Reply With Quote
The Following User Says Thank You to susarlasireesha For This Useful Post:
  #5 (permalink)  
Old 01-25-2008
Junior Member
 
Join Date: Jan 2008
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
chaitueeturi is on a distinguished road
Re: Updating a View

generally a view will be stored as a statament in database.
If u want retrieve data using this view,then it replaces the view with a select statement and it will be executed on the tables on which u created the view.I think,from this u can come to know that the data retrieved is from the updated tables only.
Reply With Quote
  #6 (permalink)  
Old 01-26-2008
Contributing Member
 
Join Date: Jul 2007
Posts: 42
Thanks: 1
Thanked 1 Time in 1 Post
priyasp_msit is on a distinguished road
Re: Updating a View

Quote:
Originally Posted by amitkannan View Post
We Create a view by using 2 tables for( ex.emp table and dept table) after that i changed some rows in the emp table what will happen in the view? whether the view also gets updated or not?


hi
u have using composite view,this does not insert or update or delete for sql but u insert or update or delete in sql only after create instead of trigger for plsql
.
Reply With Quote
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Normal View, Materialised View and Bitmap Index Geek_Guest Oracle 3 05-27-2008 11:59 PM
Inserting instead of updating krishnaindia2007 Oracle 4 10-15-2007 07:38 AM
Cyclic Updating JobHelper Oracle 2 10-13-2007 04:06 AM
Error while inserting or updating Geek_Guest SQL 1 09-09-2007 10:28 AM
Updating Java version Geek_Guest Java 1 04-16-2007 08:13 AM


All times are GMT -4. The time now is 01:46 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved