OCP 1Z0 051 121

来源:互联网 发布:网页视频录制软件 编辑:程序博客网 时间:2024/06/05 20:09
121. Which two   statements are true regarding the USING clause in table joins? (Choose two .) 
A. It can be used to join a maximum of three tables. 
B. It can be used to restrict the number of columns used in a NATURAL join. 
C. It can be used to access data from tables through equijoins as well as nonequijoins. 
D. It can be used to join tables that have columns with the same name and compatible data types. 

join语句每次都只能join俩表
当两个表列名相同时可以使用USING 与 NATURAL JOIN 
USING 与 NATURAL JOIN 都只能用于等值连接
USING 与 NATURAL JOIN 不能同时使用
SQL> create table emp2 as select empno,ename from emp;Table createdSQL> create table emp3 as select empno,deptno from emp;Table createdSQL> select * from emp2 natural join emp3;     EMPNO ENAME          DEPTNO---------- ---------- ----------      7369 SMITH              20      7499 ALLEN              30      7521 WARD               30      7566 JONES              20      7654 MARTIN             30      7698 BLAKE              30      7782 CLARK              10      7788 SCOTT              20      7839 KING               10      7844 TURNER             30      7876 ADAMS              20      7900 JAMES              30      7902 FORD               20      7934 MILLER             1014 rows selected

有些地方说列类型不同时不能使用natural join,该说法错误
SQL> drop table emp3 purge;Table droppedSQL> create table emp3 as select to_char(empno) as empno,deptno from emp;Table createdSQL> select * from emp2 natural join emp3;EMPNO                                    ENAME          DEPTNO---------------------------------------- ---------- ----------7369                                     SMITH              207499                                     ALLEN              307521                                     WARD               307566                                     JONES              207654                                     MARTIN             307698                                     BLAKE              307782                                     CLARK              107788                                     SCOTT              207839                                     KING               107844                                     TURNER             307876                                     ADAMS              207900                                     JAMES              307902                                     FORD               207934                                     MILLER             1014 rows selected

当只使用部分相同列时可以使用USING
SQL> drop table emp2 purge;Table droppedSQL> drop table emp3 purge;Table droppedSQL> create table emp2 as select * from emp;Table createdSQL> create table emp3 as select * from emp;Table createdSQL> select empno,emp2.ename,emp3.comm from emp2 join emp3 using(empno);     EMPNO ENAME            COMM---------- ---------- ----------      7369 SMITH            7499 ALLEN             300      7521 WARD              500      7566 JONES            7654 MARTIN           1400      7698 BLAKE            7782 CLARK            7788 SCOTT            7839 KING             7844 TURNER              0      7876 ADAMS            7900 JAMES            7902 FORD             7934 MILLER     14 rows selected

Answer: BD
0 0