您的位置:首页 > 编程语言 > Go语言

64.View the Exhibit and examine the data in the PROMO_CATEGORY and PROMO_COST columns of

2016-03-02 10:25 489 查看
64.View the Exhibit and examine the data in the PROMO_CATEGORY and PROMO_COST columns of

the PROMOTIONS table.

Evaluate the following two queries:

SQL>SELECT DISTINCT promo_category to_char(promo_cost)"code"

FROM promotions ORDER BY code;

SQL>SELECT DISTINCT promo_category promo_cost "code"

FROM promotions ORDER BY 1;

Which statement is true regarding the execution of the above queries?

A.Only the first query executes successfully.

B.Only the second query executes successfully.

C.Both queries execute successfully but give different results.

D.Both queries execute successfully and give the same result.

答案:B

解析:在设置列别名的时候,是不区分大小写的,数据库都会转换成大写,但是如果加上双引号后

就会保持原样,第一个sql语句,order by code,其实会转化为 order by CODE,而列别名"code"

还是保持小写,因此会报错

SQL> select '1' "code" from dual order by code;

select '1' "code" from dual order by code

*

ERROR at line 1:

ORA-00904: "CODE": invalid identifier

第二条sql语句,使用的是阿拉伯数字,它代表的其实是列的位置,从1开始
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: