码迷,mamicode.com
首页 > 其他好文 > 详细

OCP-1Z0-051-题目解析-第13题

时间:2014-11-06 21:26:26      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   ar   os   for   sp   strong   

13. View the Exhibit and examine the structure of the PRODUCTS table.

bubuko.com,布布扣
You need to generate a report in the following format:
CATEGORIES
5MP Digital Photo Camera‘s category is Photo
Y Box‘s category is Electronics
Envoy Ambassador‘s category is Hardware
Which two queries would give the required output? (Choose two.)

A. SELECT prod_name q‘‘‘s category is ‘ prod_category CATEGORIES
FROM products;
B. SELECT prod_name q‘[‘s ]‘category is ‘ prod_category CATEGORIES
FROM products;
C. SELECT prod_name q‘\‘s\‘ ‘ category is ‘ prod_category CATEGORIES
FROM products;
D. SELECT prod_name q‘<‘s >‘ ‘category is ‘ prod_category CATEGORIES
FROM products;

注意:选项中字符串之间的连接应加连接符||
Answer: CD

题目解析:
sql中字符串的两边是须要加单引號的,表示字符串的開始和结束,假设我们想在sql中输出一个实际的单引號‘,那么须要连续输入四个单引號‘‘‘‘,当中中间的两个单引號表示一个单引號。
第一个单引號:表示字符串開始
第二个单引號:表示转义,后面接的单引號转义为真正的单引號
第三个单引號:表示实际输出的单引號
第四个单引號:表示字符串结束
如:
SQL> select ‘‘‘‘ name from dual;

N
-

SQL> select ‘Camera‘‘s category is Photo‘ name from dual;

NAME
--------------------------
Camera‘s category is Photo


另外Oracle还提供了一个Q-quote的表达式,来简化SQL或PLSQL中字符串的表示,其格式为q‘[Camera‘s category is Photo]‘,输出为方括号里的原始字符串格式,当中方括号能够更换为其它的随意一对特殊符号,但必须是成对出现的,不可为q‘[Camera‘s category is Photo|‘。
如:
SQL> select q‘[Camera‘s category is Photo]‘ name from dual;

NAME
--------------------------
Camera‘s category is Photo

SQL> select q‘|Camera‘s category is ‘Photo‘|‘ name from dual;

NAME
----------------------------
Camera‘s category is ‘Photo‘

A:错误, is后面应该是两个单引號,正确的为
SELECT prod_name || q‘‘‘s category is ‘‘|| prod_category CATEGORIES
FROM products;
B:错误,category 前面少了一个‘,正确的为
SELECT prod_name || q‘[‘s ]‘||‘category is ‘||prod_category CATEGORIES FROM products;

 

OCP-1Z0-051-题目解析-第13题

标签:style   blog   http   color   ar   os   for   sp   strong   

原文地址:http://www.cnblogs.com/gcczhongduan/p/4079710.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!