OCP-1Z0-051 第120题 NATURAL JOIN自然连接

来源:互联网 发布:arcgis js 事件关闭 编辑:程序博客网 时间:2024/05/16 08:19
一、原题
View the Exhibits  and examine the structures of the PRODUCTS,  SALES,  and CUSTOMERS  tables.






You issue the following query:
SQL>SELECT p.prod_id,prod_name,prod_list_price, quantity_sold,cust_last_name
         FROM products p NATURAL JOIN sales s NATURAL JOIN customers c
         WHERE prod_id =148;
Which statement is true regarding the outcome of this query?
A. It executes successfully.
B. It produces an error because the NATURAL join can be used only with two tables.
C. It produces an error because a column used in the NATURAL join cannot have a qualifier.
D. It produces an error because all columns used in the NATURAL join should have a qualifier.

答案:C

二、题目翻译
查看PRODUCTS,  SALES,  and CUSTOMERS表的结构
执行下面的语句
关于上面语句的执行结果,下面哪句描述是正确的?
A.执行成功。
B.报错,因为NATURAL连接只能连接两个表。
C.报错,因为NATURAL连接使用的一个列不能有限定词。
D.报错,因为NATURAL连接使用的所有列应该加一个限定词。


三、题目解析
因为prod_id是用于NATURAL连接,不能加限定词(即两个表中如果有相同列名的都不能加限定词,即列名前不能带表名)。而对于ORACLE自己语法的join是需要对两个表中相同的列使用限定词的。

联机文档上有详细的描述:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_10002.htm#BABBAGAH
        The NATURAL keyword indicates that a natural join is being performed. A natural join is based on all columns in the two tables that have the same name. It selects rows from the two tables that have equal values in the relevant columns. If two columns with the same name do not have compatible data types, then an error is raised. When specifying columns that are involved in the natural join, do not qualify the column name with a table name or table alias.


自然连接的详细用法,详见:
        http://blog.csdn.net/holly2008/article/details/25501343


0 0
原创粉丝点击