2.Which three statements are true regarding the WHERE and HAVING clauses in a SQL statement? (Choose three.)
A. WHERE and HAVING clauses cannot be used together in a SQL statement.
B. The HAVING clause conditions can have aggregate functions.
C. The HAVING clause conditions can use aliases for the columns.
D. The WHERE clause is used to exclude rows before the grouping of data.
E. The HAVING clause is used to exclude one or more aggregated results after grouping data.
Correct Answer: ABD
A.一个SOL语句中,不能同时用having和where,正确。having=where+函数
B.having 可以用在聚合函数里,正确
C.不能在group by子句中使用列别名,错误
D.where 在group by 之前,错误
E.having子句用于在对数据进行分组后排除一个或者聚合结果,错误。having没有分组
5.Which two statements are true regarding roles? (Choose two.)
A. A role can be granted to itself.
B. A role can be granted to PUBLIC.
C. A user can be granted only one role at any point of time.
D. The REVOKE command can be used to remove privileges but not roles from other users.
E. Roles are named groups of related privileges that can be granted to users or other roles.
Correct Answer: BE
E.角色是可以授予用户或其他角色的相关特权组。正确
这是我翻书查到的,关于角色的理解
角色是一组命名的相关权限,这组权限可以通过这个名字授予用户或者其他的角色。但是一个角色不让能授予自己,也不能循环授予。
一个角色即包括系统权限,也可以包括对象权限。每一个角色在系统中必须是唯一的,即不能与任何现有的用户名和角色名重用,而且角色不属于任何用户,也不存在任何用户模式中。角色的描述存放在数据字典中。
19.Which two statements are true regarding the EXISTS operator used in the correlated subqueries? (Choose two.)
A. The outer query stops evaluating the result set of the inner query when the first value is found.
当找到第一个值时,外部查询停止计算内部查询的结果集 ,正确
B. It is used to test whether the values retrieved by the inner query exist in the result of the outer query.
它用于测试由内部查询检索的值是否存在于外部查询的结果中
C. It is used to test whether the values retrieved by the outer query exist in the result set of the inner query.
它用于测试外部查询检索的值是否存在于内部查询的结果集中。
D. The outer query continues evaluating the result set of the inner query until all the values in the result set are processed
外部查询继续计算内部查询的结果集,直到处理完结果集中的所有值。
Correct Answer: AC
举个栗子:
select id, name,salary
from employees
where exists (
select id
from employees
where id in (1,2,3)'
)
当内查询select id from employees where id in (1,2,3)搜索不到id为1或者2或者3的记录时,内查询返回false到外查询
当内查询select id from employees where id in (1,2,3)搜索到第一个id为1或者2或者3的记录时,内查询直接弹回true外查询
所以称exists为半查询