Processing of single quotes and String concatenation during oracle Storage
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 a single quotation mark acts as an escape character. 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. connector '|' leads to a new escape: Connection Symbol '|' there is no relationship between the single quotation marks on the left and right, unless '|' is a part of a string (which is common in dynamic SQL ). Select 'name' | ''' from dual ---- output: name' understanding: | The following string is used as a string, that is, the front and back are ', the middle is an intensive single quotation mark '', so the first escape function is select 'name''' from dual ---- output: name: 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 situation, for example, 'asdfas ', which represents a string with the displayed content asdfas and two single quotation marks, A pair is usually enclosed in a single quotation mark, indicating a single quotation mark within a single quotation mark, for example, 'sdfs' '000000' 'dfsdf ', this type of string is displayed in three or four single quotes of sdfs '000000' dfsdf, which is developed on one or two occasions, 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 |) (separate the last four single quotes, and the other two are a pair -- represents a single quotation mark within a pair of single quotes, the outer two are a pair-representing a pair of single quotes)