天天看点

ocp-047-18 create view

18. View the Exhibit and examine the data in ORDERS and ORDER_ITEMS tables. You need to create a view that displays the ORDER ID, ORDER_DATE, and the total number of items in each order. Which CREATE VIEW statement would create the view successfully?

A. CREATE OR REPLACE VIEW ord_vu (order_id,order_date) AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id) "NO OF ITEMS" FROM orders o JOIN order_items i ON (o.order_id = i.order_id) GROUP BY o.order_id,o.order_date

B. CREATE OR REPLACE VIEW ord_vu AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id) "NO OF ITEMS" FROM orders o JOIN order_items i ON (o.order_id = i.order_id) GROUP BY o.order_id,o.order_date

C. CREATE OR REPLACE VIEW ord_vu AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id) FROM orders o JOIN order_items i ON (o.order_id = i.order_id) GROUP BY o.order_id,o.order_date

D. CREATE OR REPLACE VIEW ord_vu AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)||' NO OF ITEMS' FROM orders o JOIN order_items i ON (o.order_id = i.order_id) GROUP BY o.order_id,o.order_date WITH CHECK OPTION

答案: B

分析: 本题考点是视图/view

创建视图的命令格式为:

create or replace view view_name as (select...from...)

A. 视图的列名是通过select语句指定的。

C. 没有为COUNT(i.line_item_id)列取别名,别人查看视图时无法了解该列的含义。

D. ||用来连接2个字符串