If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Validating DB2 views

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-13-04, 15:48
nic39 nic39 is offline
Registered User
 
Join Date: Jan 2004
Posts: 10
Validating DB2 views

1. drop view...
2. create view ...

Is this the only way a view can be validated against
a change in underlying table. (for Db2 8.1)

Thanks

nic
Reply With Quote
  #2 (permalink)  
Old 05-13-04, 15:50
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Yes

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 05-14-04, 13:32
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
correct me if I am wrong.It also done implicitily by database,only if the defination matches the new table defination

regards,

mujeeb
Reply With Quote
  #4 (permalink)  
Old 05-14-04, 13:53
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Thanks for pointing out Mujeeb ..

Looks like, even if the definition of the view is different, if you create a view with the name of an invalid view, it is replaced.

So, for the original question,

Just issue a CREATE VIEW Statement, and DB2 will replace the invalid view.


HTH

Sathyaram

[dba01][/dba01]$db2 "create table t1(i int,j int)"
DB20000I The SQL command completed successfully.
[dba01][/dba01]$db2 "create view v1 as select i,j from t1"
DB20000I The SQL command completed successfully.
[dba01][/dba01]$db2 drop table t1
DB20000I The SQL command completed successfully.
[dba01][/dba01]$db2 -x "select viewname,valid from syscat.views where viewname='V1'"
V1 X
[dba01][/dba01]$db2 "create table t1(i int,j int)"
DB20000I The SQL command completed successfully.
[dba01][/dba01]$db2 "create view v1 as select i from t1"
SQL0280W View, trigger or summary table "DBA01.V1" has replaced an existing
inoperative view, trigger or summary table. SQLSTATE=01595
[dba01][/dba01]$
[dba01][/dba01]$db2 -x "select viewname,valid from syscat.views where viewname='V1'"
V1 Y
[dba01][/dba01]$
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 05-14-04, 16:17
nic39 nic39 is offline
Registered User
 
Join Date: Jan 2004
Posts: 10
Thank you all.
Reply With Quote
  #6 (permalink)  
Old 08-23-04, 10:37
lets lets is offline
Registered User
 
Join Date: Aug 2004
Posts: 1
recompiling invalid views

Hello all,
Can anybody help me with this scenario.
We have nested views..A view dependent on another and the nested views
are around 15-20.

Thats correct there are many views dependent on each other.
I made a change to one of the base view and I know the dependency tree too.there are around 15 views dependent on the view I changed.
when the change was made, all the views in the dependency tree became invalid objects is there any way to recompile (views) automaically like in oracle I know there is a way to do so..How do we do in DB2?

Thanks in advance..
lets.
lets_form_group@yahoo.com
Reply With Quote
  #7 (permalink)  
Old 08-23-04, 10:43
lets lets is offline
Registered User
 
Join Date: Aug 2004
Posts: 1
recompiling invalid views

Hello all,
Can anybody help me with this scenario.
We have nested views..A view dependent on another and the nested views
are around 15-20.

Thats correct there are many views dependent on each other.
I made a change to one of the base view and I know the dependency tree too.there are around 15 views dependent on the view I changed.
when the change was made, all the views in the dependency tree became invalid objects is there any way to recompile (views) automaically like in oracle I know there is a way to do so..How do we do in DB2?

Thanks in advance..
lets.
lets_form_group@yahoo.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On