Which views can have all DML operations performed on it? (Choose all that apply.)
A.CREATE VIEW v3 AS SELECT * FROM SALES WHERE cust_id = 2034 WITH CHECK OPTION;
B.CREATE VIEW v1 AS SELECT * FROM SALES WHERE time_id <= SYSDATE - 2*365 WITH CHECK OPTION;
C.CREATE VIEW v2 AS SELECT prod_id, cust_id, time_id FROM SALES
WHERE time_id <= SYSDATE - 2*365 WITH CHECK OPTION;
D.CREATE VIEW v4 AS SELECT prod_id, cust_id, SUM(quantity_sold) FROM SALES
WHERE time_id <= SYSDATE - 2*365 GROUP BY prod_id, cust_id
WITH CHECK OPTION;
答案:AB
解析:这道题问的是那个语句创建的视图,可以执行所有的dml语句,
dml语句指的是insert,update,delete,merge
从图中可以看到sales表中每个字段都不能为null,因此如果insert的时候,视图必须包括所有的列
创建视图中with check option 的意思是,执行所有的dml语句只能符合该视图能看到的,也即是满足where条件的
比如A选项,如果insert的话,只能插入cust_id列为2034,其他是无法插入的
A.正确
B.正确
C.错误,缺少了3个列,无法执行insert语句
D.错误,缺少了四个列,并且还有聚合,更无法执行insert语句