OCP-1Z0-051-Question Analysis-13th question

Source: Internet
Author: User

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;

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.