Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

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 view? ...

Go Back   Geeks Talk > Databases > SQL
Register Blogs FAQ Tag Cloud 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 06: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
Location: Bangalore
Posts: 515
Thanks: 29
Thanked 63 Times in 61 Posts
susarlasireesha will become famous soon enough
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: 23
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: 43
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

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


All times are GMT -4. The time now is 06:05 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved