34. View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS
tables. Evaluate the following SQL statement:
SELECT oi.order_id, product_id, order_date
FROM order_items oi JOIN orders o USING(order_id).
Which statement is true regarding the execution of this SQL statement?
A. The statement would not execute because table aliases are not allowed in
the JOIN clause.
B. The statement would not execute because the table alias prefix is not used
in the USING clause.
C. The statement would not execute because all the columns in the SELECT
clause are not prefixed with table aliases.
D. The statement would not execute because the column part of the USING clause
cannot have a qualifier in the SELECT list.
Answer: D
SQL> SELECT oi.order_id, o.product_id, order_date
2 FROM orders oi JOIN order_items o USING(order_id);
SELECT oi.order_id, o.product_id, order_date
FROM orders oi JOIN order_items o USING(order_id)
ORA-25154: USING 子句的列部分不能有限定词
SQL>
SQL> SELECT o.order_id, o.product_id, order_date
2 FROM orders oi
3 JOIN order_items o
4 USING (order_id);
SELECT o.order_id, o.product_id, order_date
FROM orders oi
JOIN order_items o
USING (order_id)
ORA-25154: USING 子句的列部分不能有限定词
SQL>
SQL> SELECT order_id, o.product_id, order_date
2 FROM orders oi
3 JOIN order_items o
4 USING (order_id);
ORDER_ID PRODUCT_ID ORDER_DATE
---------- ---------- --------------------------------------------------------------------------------
100 1
101 2
102 4
103 5