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开始
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开始
相关文章推荐
- Windows 下用 gogs 配置局域网 git server
- golang的连接池例子
- 原创翻译:James Whittaker系列——Google是如何测试的(3)
- 1.NSString+category
- Fcitx下的Google拼音和云拼音
- VIEWGOOD(远古)电力行业流媒体项目
- [Google EarlGrey] 0x02 API 简介
- django1.9使用django-pageination出现AttributeError错误处理
- Euclid‘s algorithm
- SGOI 海上搜索 状压DP
- Django基础——Form&Ajax篇
- 算法代码实现之堆排序,Golang(Go语言)实现
- 【CodeForces】A. Dragons
- 熟悉一下GO的AES加密库
- Django~static files
- Django中的F表达式来解决丢失修改问题
- 关于Go语言共享内存操作的小实例
- Xcode警告Category is implementing a method which will also be implemented by its primary class 处理
- POJ2195 Going Home(SPFA最小费用最大流)
- go liteIDE