OCP 1Z0 051 13

13. View the Exhibit and examine the structure of the PRODUCTS table. 
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.)  
OCP 1Z0 051 13_第1张图片

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; 
考点:

q-quote

1) q-quote界定符可以是除了TAB,空格,回车外的任何单字节或多字节字符。

2) 除了单字节的的开始界定符是[,{,<,(,那么结束界定符必须是],},>,)  其他开始界定符与结束界定符必须一致
q-quote界定符的内字符串可示为单引号。而字符串的起止位置以界定符为准。


样题内容有误,估计应该为如下所示
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;

a 把界定符与双写单引号的方法搞混了
SQL> SELECT '双写'',两个单引号显示为一个' AS s FROM dual;
S
---------------------------
双写',两个单引号显示为一个


SQL> SELECT q'[界定符内',一个单引号即可]' AS s FROM dual;
S
-------------------------
界定符内',一个单引号即可


b 少了一个单引号,正确写法为

SQL> SELECT prod_name || q'['s ]' || ' category is ' || prod_category categories
  2    FROM products
  3   WHERE rownum <= 2;
CATEGORIES
--------------------------------------------------------------------------------
5MP Telephoto Digital Camera's  category is Photo
17" LCD w/built-in HDTV Tuner's  category is Peripherals and Accessories


Answer: CD 


SQL> SELECT prod_name ||  q'\'s\'  || ' category is ' ||  prod_category CATEGORIES FROM products
  2  where rownum <=2;

CATEGORIES
-------------------------------------------------------------------------------------------------------------------
5MP Telephoto Digital Camera's category is Photo
17" LCD w/built-in HDTV Tuner's category is Peripherals and Accessories

已选择2行。


SQL>
SQL> SELECT prod_name ||  q'<'s >' ||  'category is ' ||  prod_category CATEGORIES FROM products
  2  where rownum <=2;

CATEGORIES
-------------------------------------------------------------------------------------------------------------------
5MP Telephoto Digital Camera's category is Photo
17" LCD w/built-in HDTV Tuner's category is Peripherals and Accessories

已选择2行。


你可能感兴趣的:(OCP 1Z0 051 13)