Given the following DDL and INSERT statements: CREATE VIEW v1 AS SELECT col1 FROM t1 WHERE col1 > 10; CREATE VIEW v2 AS SELECT col1 FROM v1 WITH CASCADED CHECK OPTION; CREATE VIEW v3 AS SELECT col1 FROM v2 WHERE col1 < 100; INSERT INTO v1 VALUES(5); INSERT INTO v2 VALUES(5); INSERT INTO v3 VALUES(20); INSERT INTO v3 VALUES(100); How many of these INSERT statements will be successful? What is the expected sequence of value returned from the below query? SELECT Product-ID, Quantity from Customer ORDER BY Product-ID;
C
Correct answer
Explanation
This question contains two separate questions - the first about INSERT success count and another about query results. For the INSERT question: View v1 has a filter (col1 > 10) but no CHECK OPTION, so INSERT INTO v1 VALUES(5) succeeds despite violating the filter. View v2 uses WITH CASCADED CHECK OPTION, which means the INSERT must satisfy both v2's filter and all underlying views' filters, so INSERT INTO v2 VALUES(5) fails. View v3 inherits the check option from v2, so INSERT INTO v3 VALUES(20) succeeds (meets both conditions) but INSERT INTO v3 VALUES(100) fails (violates v1's > 10 constraint). Thus exactly 2 INSERTs succeed.