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 enclosed by single quotation marks. If we want to output an actual single quotation mark in SQL ', you must enter four single quotes ''' in a row. The two single quotes in the middle represent one single quotation mark.
The first single quotation mark indicates the start of the string.
Second single quotes: escape. The following single quotes are escaped as true single quotes.
Third single quotes: single quotes indicating the actual output
The fourth single quotation mark 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. Square brackets can be replaced with any other special symbol, but must appear in pairs, 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 must be followed by two single quotes. 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;