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>