Results 1 to 6 of 6

Thread: Db2 question

  1. #1
    Join Date
    Oct 2007
    Posts
    6

    Unanswered: 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,

  2. #2
    Join Date
    Jan 2003
    Posts
    1,605
    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

  3. #3
    Join Date
    Oct 2007
    Posts
    6
    Thanks for your reply

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  5. #5
    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?

  6. #6
    Join Date
    Jan 2003
    Posts
    1,605
    @stolze, I have overlooked v1, t1 names so similar... Thanks for info.
    @Joseph_T, if which check is specified the last insert will fail.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •