Oracle Certificate Profession 1Z0-051-07

LuiseDalian發表於2014-05-08
(7)Which two statements are true regarding the USING and ON clauses in table joins? (Choose two.)

A. Both USING and ON clauses can be used for equijoins and nonequijoins.

B. A maximum of one pair of columns can be joined between two tables using the ON clause.

C. The ON clause can be used to join tables on columns that have different names but compatible data types.

D. The WHERE clause can be used to apply additional conditions in SELECT statements containing the ON or the USING clause.

答案:(C、D)

解析:

--A(X), USING只能用於等值連線

--B(X), 可以指定多個pair of columns

select e.empno, e.ename, e.deptno, d.loc

from emp e join dept d

on(e.deptno = d.deptno and d.deptno = e.deptno)

where empno = 7788;

--D

--ON可以與WHERE一起使用

select e.empno, e.ename, e.deptno, d.deptno, d.loc

from emp e join dept d

on(e.deptno = d.deptno)

where e.empno = 7788;

     EMPNO ENAME       DEPTNO   DEPTNO LOC

---------- ---------- ---------- ---------- -------------

      7788 SCOTT                20           20  DALLAS

     

--USING可以和WHERE一起使用

select e.empno, e.ename, deptno, d.loc

from emp e join dept d

using(deptno)

where empno = 7788;

     EMPNO ENAME          DEPTNO LOC

---------- ---------- ---------- -------------

      7788 SCOTT              20 DALLAS

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17013648/viewspace-1156380/,如需轉載,請註明出處,否則將追究法律責任。

相關文章