Processing of single quotes and String concatenation during Oracle Storage

Source: Internet
Author: User
In Oracle, single quotes have two functions: one is that strings are referenced by single quotes, and the other is escape. The use of single quotes is proximity matching, that is, proximity principle. In single quotes, this function is used as an escape character.

In Oracle, single quotes have two functions: one is that strings are referenced by single quotes, and the other is escape. The use of single quotes is proximity matching, that is, proximity principle. In single quotes, this function is used as an escape character.

In Oracle, single quotes have two functions: one is that strings are referenced by single quotes, and the other is escape. The use of single quotes is proximity matching, that is, proximity principle. It is not easy to understand when single quotes act as escape roles

1. It is regarded as an escape character starting from the second single quotation mark. If the second single quotation mark is followed by a single quotation mark (even if there is only one ).

Select ''' from dual ---- output :'

Explanation: The second single quotation mark is used as an escape character, and the third single quotation mark is escaped. It is better to understand the SQL statement as follows:

Select ''' from dual ---- output :'

2. the connector '|' leads to a new round of escape: Connection Symbol '|' there is no relationship between the left and right single quotes, unless '|' is a part of a string (which is common in dynamic SQL ).

Select 'name' | ''' from dual ---- output: name'

Understanding: | it is followed by a string, that is, the front and back are ', and the middle is an intensive single quotation mark'. Therefore, the first character is an escape function.

Select 'name''' from dual ---- output: name''

Understanding: the first and last single quotes are used as string references, and the four single quotes are escaped in two.

Here are a few simple examples:

A single quotation mark is the most normal case, for example, 'asdfas ', which represents a string and the displayed content is asdfas;

Two single quotes, which appear in pairs within a single quotes, indicate single quotes within a single quotes, such

'Sdfs' '000000' 'dfsdf '. When this string is displayed, sdfs '000000' dfsdf is used.

Three or four single quotes are developed based on one or two quotes, for example, 'asd ''' | input value | '''', the displayed content is:

Asd 'input value '.

(Separate one pair of two single quotes, one part before | and the other part after |)

(The last four single quotes are separated. The two in the middle are one pair, which represents a single pair of single quotes in a pair of single quotes, and the other two are one pair, which represents a single pair of single quotes)

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.