QUESTION 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.)
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;
答案:CD
解析:
--A选项报错;
SQL> SELECT prod_name ||q'' || 's category is ' || prod_category CATEGORIES FR
M products;
ERROR:
ORA-01756: 引号内的字符串没有正确结束
--B选项报错;
SQL> SELECT prod_name || q'['s] || 'category is ' || prod_categoryCATEGORIES
FROM products;
ERROR:
ORA-01756: 引号内的字符串没有正确结束
--C选项执行正确
SQL> SELECT prod_name || q'\'s\' || 'category is ' || prod_category CATEGORIE
FROM products;
CATEGORIES
-------------------------------------------------------------------------------
test'scategory is testcategory
Envoy Ambassador'scategory is Hardware
Y Box'scategory is Electronics
5MP Digital Photo Camera'scategory is Photo
--D选项执行正确
SQL> SELECT prod_name || q'<'s>' || 'category is ' || prod_category CATEGORIE
FROM products;
CATEGORIES
-------------------------------------------------------------------------------
test'scategory is testcategory
Envoy Ambassador'scategory is Hardware
Y Box'scategory is Electronics
5MP Digital Photo Camera'scategory is Photo
SQL>