OCP-1Z0-051 第152题 union操作的注意事项
来源:互联网 发布:鞍山plc编程培训 编辑:程序博客网 时间:2024/06/06 03:59
一、原题
二、题目翻译
三、题目解析
四、测试
SQL> create table t1(id int);
Table created.
SQL> insert into t1 values(1);
1 row created.
SQL> insert into t1 values(null);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
ID
----------
1
2 rows selected.
SQL> create table t2(id int);
Table created.
SQL> insert into t2 values(2);
1 row created.
SQL> insert into t2 values(null);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t2;
ID
----------
2
2 rows selected.
SQL> select * from t1
2 union
3 select * from t2;
ID
----------
1
2
3 rows selected.
两行null,已经去掉了一行,表示去重时,不忽略空值。
SQL> select id,null from t1
2 union
3 select id from t2;
select id,null from t1
*
ERROR at line 1:
ORA-01789: query block has incorrect number of result columns
列的数量和类型必须一致。
Which statement is true regarding the UNION operator?
A. By default, the output is not sorted.
B. NULL values are not ignored during duplicate checking.
C. Names of all columns must be identical across all SELECT statements.
D. The number of columns selected in all SELECT statements need not be the same.
答案:B
A. By default, the output is not sorted.
B. NULL values are not ignored during duplicate checking.
C. Names of all columns must be identical across all SELECT statements.
D. The number of columns selected in all SELECT statements need not be the same.
答案:B
二、题目翻译
关于UNION操作符哪句话正确?
A.默认输出不排序。
B.在重复值检查时不忽略NULL值。
C.列名在所有SELECT语句中必须是相同的。
D.在所有SELECT语句中选择的列的数量不需要相同。
A.默认输出不排序。
B.在重复值检查时不忽略NULL值。
C.列名在所有SELECT语句中必须是相同的。
D.在所有SELECT语句中选择的列的数量不需要相同。
三、题目解析
A选项不正确,因为默认输出排序。
B选项正确,因为集合不忽略null值,并且在去重时会认为null和null是相等的,去重。
C选项不正确,因为SELECT语句中的列名不必是相同的,但是数据类型是需要匹配的。
D选项不正确,因为列的数量要相同。
B选项正确,因为集合不忽略null值,并且在去重时会认为null和null是相等的,去重。
C选项不正确,因为SELECT语句中的列名不必是相同的,但是数据类型是需要匹配的。
D选项不正确,因为列的数量要相同。
四、测试
SQL> create table t1(id int);
Table created.
SQL> insert into t1 values(1);
1 row created.
SQL> insert into t1 values(null);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
ID
----------
1
2 rows selected.
SQL> create table t2(id int);
Table created.
SQL> insert into t2 values(2);
1 row created.
SQL> insert into t2 values(null);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t2;
ID
----------
2
2 rows selected.
SQL> select * from t1
2 union
3 select * from t2;
ID
----------
1
2
3 rows selected.
SQL> select id,null from t1
2 union
3 select id from t2;
select id,null from t1
*
ERROR at line 1:
ORA-01789: query block has incorrect number of result columns
S
QL> select id nid from t1
2 union
3 select id from t2;
NID
----------
1
2
3 rows selected.
名字可以不一致。QL> select id nid from t1
2 union
3 select id from t2;
NID
----------
1
2
3 rows selected.
0 0
- OCP-1Z0-051 第152题 union操作的注意事项
- OCP-1Z0-051 补充题库 第27题 UNION的注意事项
- OCP-1Z0-051 第40题 视图的注意事项
- OCP-1Z0-051 第41题 视图的注意事项
- OCP-1Z0-051 第42题 视图的注意事项
- OCP-1Z0-051 第170题 DELETE的注意事项
- OCP-1Z0-051 第175题 savepoint的注意事项
- OCP-1Z0-051 第9题 集合操作INTERSECT注意事项
- OCP-1Z0-051 第38题 视图注意事项
- OCP-1Z0-051 第135题 子查询注意事项
- OCP-1Z0-051 第167题 DELETE语句注意事项
- OCP-1Z0-051 第45题 SEQUENCE(序列)的注意事项
- OCP-1Z0-051 第139题 子查询的注意事项
- OCP-1Z0-051 第172题 事务savepoint的注意事项
- OCP-1Z0-051 补充题库 第5题 主查询和子查询的注意事项
- OCP-1Z0-051 补充题库 第17题 约束的注意事项
- OCP-1Z0-051 补充题库 第20题 约束的注意事项
- OCP-1Z0-051 补充题库 第31题 subquery子查询的注意事项
- Create a USB Virtual COM Port
- RTP编程(2)
- ACM练习之《hfut闪光的指压师》
- LA3602-水题
- 完善的vim配置代码
- OCP-1Z0-051 第152题 union操作的注意事项
- [Webservice]SoapUI 调试和生成soap模板
- JQuery选择器
- vim插件的安装与配置
- TortoiseGit安装与使用
- cocos2d基础篇笔记四
- sizeof
- 从mysql的data文件夹(*.frm,*.ibd,ibdata1)下恢复原来数据库的表及其数据(无语但是百发百中的方法)
- Application简介(二)--重写应用程序的生命周期事件