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)