OCP 1Z0 051 165
来源:互联网 发布:做项目计划软件 编辑:程序博客网 时间:2024/06/05 11:21
165. View the Exhibit and examine the description for the CUSTOMERS table.
You want to update the CUST_INCOME_LEVEL and CUST_CREDIT_LIMIT columns for the customer
with the CUST_ID 2360. You want the value for the CUST_INCOME_LEVEL to have the same value as
that of the customer with the CUST_ID 2560 and the CUST_CREDIT_LIMIT to have the same value as
that of the customer with CUST_ID 2566.
Which UPDATE statement will accomplish the task?
A. UPDATE customers
SET cust_income_level = (SELECT cust_income_level
FROM customers
WHERE cust_id = 2560),
cust_credit_limit = (SELECT cust_credit_limit
FROM customers
WHERE cust_id = 2566)
WHERE cust_id=2360;
B. UPDATE customers
SET (cust_income_level,cust_credit_limit) = (SELECT
cust_income_level, cust_credit_limit
FROM customers
WHERE cust_id=2560 OR cust_id=2566)
WHERE cust_id=2360;
C. UPDATE customers
SET (cust_income_level,cust_credit_limit) = (SELECT
cust_income_level, cust_credit_limit
FROM customers
WHERE cust_id IN(2560, 2566)
WHERE cust_id=2360;
D. UPDATE customers
SET (cust_income_level,cust_credit_limit) = (SELECT
cust_income_level, cust_credit_limit
FROM customers
WHERE cust_id=2560 AND cust_id=2566)
WHERE cust_id=2360;
B C cust_id=2560 OR cust_id=2566 与 cust_id IN(2560, 2566) 结果一样。当然C 还少了半个括号“)”
B 与 C均返回两条记录,一是不符合需求,二是返回两行值让oracle取哪一个,玩儿“你猜”游戏?
D 与 BC相关,用了 and ,结条件变成了什么,2560 = 2566?这当然不会返回值了。
A是对的
Answer: A
You want to update the CUST_INCOME_LEVEL and CUST_CREDIT_LIMIT columns for the customer
with the CUST_ID 2360. You want the value for the CUST_INCOME_LEVEL to have the same value as
that of the customer with the CUST_ID 2560 and the CUST_CREDIT_LIMIT to have the same value as
that of the customer with CUST_ID 2566.
Which UPDATE statement will accomplish the task?
A. UPDATE customers
SET cust_income_level = (SELECT cust_income_level
FROM customers
WHERE cust_id = 2560),
cust_credit_limit = (SELECT cust_credit_limit
FROM customers
WHERE cust_id = 2566)
WHERE cust_id=2360;
B. UPDATE customers
SET (cust_income_level,cust_credit_limit) = (SELECT
cust_income_level, cust_credit_limit
FROM customers
WHERE cust_id=2560 OR cust_id=2566)
WHERE cust_id=2360;
C. UPDATE customers
SET (cust_income_level,cust_credit_limit) = (SELECT
cust_income_level, cust_credit_limit
FROM customers
WHERE cust_id IN(2560, 2566)
WHERE cust_id=2360;
D. UPDATE customers
SET (cust_income_level,cust_credit_limit) = (SELECT
cust_income_level, cust_credit_limit
FROM customers
WHERE cust_id=2560 AND cust_id=2566)
WHERE cust_id=2360;
B C cust_id=2560 OR cust_id=2566 与 cust_id IN(2560, 2566) 结果一样。当然C 还少了半个括号“)”
B 与 C均返回两条记录,一是不符合需求,二是返回两行值让oracle取哪一个,玩儿“你猜”游戏?
SQL> SELECT cust_income_level, cust_credit_limit 2 FROM sh.customers 3 WHERE cust_id = 2560 4 OR cust_id = 2566;CUST_INCOME_LEVEL CUST_CREDIT_LIMIT------------------------------ -----------------B: 30,000 - 49,999 3000I: 170,000 - 189,999 30002 rows selected
SQL> UPDATE sh.customers 2 SET (cust_income_level, cust_credit_limit) = 3 (SELECT cust_income_level, cust_credit_limit 4 FROM sh.customers 5 WHERE cust_id = 2560 6 OR cust_id = 2566) 7 WHERE cust_id = 2360;UPDATE sh.customers SET (cust_income_level, cust_credit_limit) = (SELECT cust_income_level, cust_credit_limit FROM sh.customers WHERE cust_id = 2560 OR cust_id = 2566) WHERE cust_id = 2360ORA-01427: single-row subquery returns more than one row
D 与 BC相关,用了 and ,结条件变成了什么,2560 = 2566?这当然不会返回值了。
SQL> SELECT COUNT(*) 2 FROM sh.customers 3 WHERE cust_id = 2560 4 AND cust_id = 2566; COUNT(*)---------- 01 row selected
A是对的
SQL> SELECT cust_income_level, 2 (SELECT cust_income_level FROM sh.customers WHERE cust_id = 2560) AS cust_income_level2, 3 cust_credit_limit, 4 (SELECT cust_credit_limit FROM sh.customers WHERE cust_id = 2566) AS cust_credit_limit2 5 FROM sh.customers 6 WHERE cust_id = 2360;CUST_INCOME_LEVEL CUST_INCOME_LEVEL2 CUST_CREDIT_LIMIT CUST_CREDIT_LIMIT2------------------------------ ------------------------------ ----------------- ------------------G: 130,000 - 149,999 B: 30,000 - 49,999 5000 30001 row selected
SQL> UPDATE sh.customers 2 SET cust_income_level = 3 (SELECT cust_income_level FROM sh.customers WHERE cust_id = 2560), 4 cust_credit_limit = 5 (SELECT cust_credit_limit FROM sh.customers WHERE cust_id = 2566) 6 WHERE cust_id = 2360;1 row updatedSQL> SELECT cust_income_level, cust_credit_limit 2 FROM sh.customers 3 WHERE cust_id = 2360;CUST_INCOME_LEVEL CUST_CREDIT_LIMIT------------------------------ -----------------B: 30,000 - 49,999 30001 row selected
Answer: A
0 0
- OCP 1Z0 051 165
- OCP 1Z0 052 165
- OCP 1Z0 053 165
- OCP 1Z0 051 1
- OCP 1Z0 051 2
- OCP 1Z0 051 3
- OCP 1Z0 051 4
- OCP 1Z0 051 5
- OCP 1Z0 051 6
- OCP 1Z0 051 7
- OCP 1Z0 051 8
- OCP 1Z0 051 9
- OCP 1Z0 051 10
- OCP 1Z0 051 11
- OCP 1Z0 051 12
- OCP 1Z0 051 13
- OCP 1Z0 051 14
- OCP 1Z0 051 15
- css3 -> 多栏布局
- Android画图Path的使用
- 线段树及其基本操作
- linux+nginx+python+django环境配置
- 设计模式(22)-行为型模式-Template Method模式
- OCP 1Z0 051 165
- 程序员的奋斗史(三十八)——大学断代史(二)——我与数据库的故事
- iOS中集合遍历方法的比较和技巧
- 学会查看错误日志!!!
- 8086汇编排序(冒泡、选择、快速)
- 设计模式(23)-行为型模式-VISITOR模式
- POJ2983 查分约束系统
- Cross-site scripting with UTF-7
- Mina源码阅读笔记(四)—Mina的连接IoConnector1