38.Which two statements are true regarding views? (Choose two.)
A.A simple view in which column aliases have been used cannot be updated.
B.Rows cannot be deleted through a view if the view definition contains the DISTINCT keyword.
C.Rows added through a view are deleted from the table automatically when the view is dropped.
D.The OR REPLACE option is used to change the definition of an existing view without dropping and re-creating it.
E.The WITH CHECK OPTION constraint can be used in a view definition to restrict the columns displayed through the view.
答案:BD
解析:
A:题目说的是一个简单视图中使用了列别名不能用于update,这个是错误的
SQL> create table test(a varchar2(10));
Table created.
SQL> create view v_test as select a as aa from test;
View created.
SQL> insert into test values ('1');
1 row created.
SQL> update v_test set aa='2';
1 row updated.
SQL> select * from test;
A
----------
2
SQL> commit;
Commit complete.
B:正确,如果视图定义包含DISTINCT关键字,那么不能通过视图删除数据
C:错误,题目说的是通过视图增加的数据,当视图删除的时候数据自动删除,显然是不正确的
D:正确,or replace用于不需要删除就可以进行修改结构,他的最大好处是权限不需要处理
E:错误,这里说WITH CHECK OPTION的作用是是通过视图限制列的显示,这显然是不正确的,他的作用
是执行所有的dml语句只能符合该视图能查到的,也即是满足where条件的
A.A simple view in which column aliases have been used cannot be updated.
B.Rows cannot be deleted through a view if the view definition contains the DISTINCT keyword.
C.Rows added through a view are deleted from the table automatically when the view is dropped.
D.The OR REPLACE option is used to change the definition of an existing view without dropping and re-creating it.
E.The WITH CHECK OPTION constraint can be used in a view definition to restrict the columns displayed through the view.
答案:BD
解析:
A:题目说的是一个简单视图中使用了列别名不能用于update,这个是错误的
SQL> create table test(a varchar2(10));
Table created.
SQL> create view v_test as select a as aa from test;
View created.
SQL> insert into test values ('1');
1 row created.
SQL> update v_test set aa='2';
1 row updated.
SQL> select * from test;
A
----------
2
SQL> commit;
Commit complete.
B:正确,如果视图定义包含DISTINCT关键字,那么不能通过视图删除数据
C:错误,题目说的是通过视图增加的数据,当视图删除的时候数据自动删除,显然是不正确的
D:正确,or replace用于不需要删除就可以进行修改结构,他的最大好处是权限不需要处理
E:错误,这里说WITH CHECK OPTION的作用是是通过视图限制列的显示,这显然是不正确的,他的作用
是执行所有的dml语句只能符合该视图能查到的,也即是满足where条件的