自然连接(NATURAL JOIN)
自然连接(NATURAL JOIN)是一种特殊的等价连接,它将表中具有相同名称的列自动进行记录匹配。自然连接不必指定任何同等连接条件。
自然连接自动判断相同名称的列,而后形成匹配。缺点是,虽然可以指定查询结果包括哪些列,但不能人为地指定哪些列被匹配。
1.如果做自然连接的两个表的有多个字段都满足有相同名称个类型,那么他们会被作为自然连接的条件。
2.如果自然连接的两个表仅是字段名称相同,但数据类型不同,那么将会返回一个错误。
3.由于oracle中可以进行这种非常简单的natural join,我们在设计表时,应该尽量在不同表中具有相同含义的字段使用相同的名字和数据类型。以方便以后使用natural join
4.连接的的表不能有修饰符
View theExhibits and examine the structures of the PRODUCTS, SALES, and CUSTOMERS tables. You issuethe following query:
SELECT p.prod_id, prod_name, prod_list_price, quantity_sold,
cust_last_name
FROM products p NATURALJOIN sales s NATURALJOIN customers c
WHERE prod_id = 148 ;
A. Itexecutes successfully.Whichstatement is true regarding the outcome of this query?
B. Itproduces an error because the NATURAL join can be used only with two tables.
C. It produces an error because a columnused in the NATURAL join cannot have aqualifier.
D. Itproduces an error because all columns used in the NATURAL join should have aqualifier.