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 wowould 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;
Note: the connection between strings in the option should contain a connector |
Answer: CD
Question analysis:
In SQL, the start and end of a string must be added with a single quote. Suppose we want to output an actual single quote in SQL ', therefore, you must enter four single quotes ''' in a row. The two single quotes in the middle indicate one single quote.
The first parameter indicates the start of a string.
Second single quote escape: Escape. The next single quote escape is the real single quote escape.
The third single quote: indicates the actual output single quote
Fourth single quote: indicates that the string ends.
For example:
SQL> select ''' name from dual;
N
-
'
SQL> select 'camera's category is Photo 'name from dual;
NAME
--------------------------
Camera's category is Photo
In addition, Oracle provides a Q-quote expression to simplify the expression of strings in SQL or PLSQL. The format is Q' [Camera's category is Photo] '. the output is the original string format in square brackets. When Chinese brackets can be replaced with other random special characters, they must be paired, it cannot be Q' [Camera's category is Photo | '.
For example:
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: error. is followed by two single-quote leads. Correct:
SELECT prod_name | Q''' s category is ''| prod_category CATEGORIES
FROM products;
B: error. A 'is missing before category. Correct:
SELECT prod_name | Q' ['s] '| 'Category is' | prod_category categories from products;
OCP-1Z0-051-question Analysis-13th question