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 > Db2 question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-30-07, 05:37
Joseph_T Joseph_T is offline
Registered User
 
Join Date: Oct 2007
Posts: 6
Db2 question

Please tell me the answer for the below question, if you are sure about it.

With DBADM authority on the database and given the statements:
CREATE TABLE t1 (c1 CHAR(1))
INSERT INTO t1 VALUES ('b')
CREATE VIEW v1 AS SELECT c1 FROM t1 WHERE c1 ='a'
INSERT INTO v1 VALUES ('a')
INSERT INTO v1 VALUES ('b')
How many rows would be returned from the statement, SELECT c1 FROM t1?

Thanks,
Reply With Quote
  #2 (permalink)  
Old 10-30-07, 05:42
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
2 rows, because 'create view' is not specified 'with check option'.

Tip: if you would like to learn something about DB2 try executing your commands to DB2 database and then check the result.

Hope this helps,
Grofaty
Reply With Quote
  #3 (permalink)  
Old 10-30-07, 05:49
Joseph_T Joseph_T is offline
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks for your reply
Reply With Quote
  #4 (permalink)  
Old 10-30-07, 06:26
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
3 rows are returned. The final SELECT goes against the underlying table and not the view.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 10-30-07, 07:12
Joseph_T Joseph_T is offline
Registered User
 
Join Date: Oct 2007
Posts: 6
I think you are correct Stolze. And also in case if WITH CHECK option is specified, the last INSERT will fail right?
Reply With Quote
  #6 (permalink)  
Old 10-30-07, 07:53
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
@stolze, I have overlooked v1, t1 names so similar... Thanks for info.
@Joseph_T, if which check is specified the last insert will fail.
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