In ORACLE:
Double quotation marks are used as follows:Object CreationWhen,Object Name and field nameDouble quotation marksOracle will be case sensitiveOtherwise, both of them are capitalized by default.
The single quotation marks indicate that the field with single quotation marks isA word is similar to a string., Not case sensitive.
Single quotes are used to identify the differences between characters and numbers.
When a string text is specified, the string text must be enclosed in single quotes.
Before Oracle10g, if the string text contains single quotes, you must use two single quotes. For example: I'm
A string!
The string text is: string_var: = 'I'm
A string! '
Other delimiters (<>, [], {}, etc.) can be used in Oracle10g. Note that when using these delimiters, you must not only add single quotation marks before and after the delimiters, but also contain the prefix Q. example: string_var: = Q' [I'm
A string!] ';
For example
Select
* From table_name where id = 1; this indicates that the queried number is
Select
* From table_name where id = '1'; this indicates that the query is a character.
Suppose that the double quotation marks are like this. If you have a table field named sysdate, because sysdate is a special character in Oracle, when you want to query this field
Select
"Sysdate" from table_name;
But if you use
Select
'Sysdate' from table_name;
The result is sysdate.
The following update statement cannot be used: Update
Device set dept = 'select * From message where name = 'Tom '';
Handling essentials:
Update
Device set dept = 'select * From message where name = ''tom ''where id = 3 ';
Execution successful.
Originally,Two''
A'
Single quotes in
Oracle has three identities:
1. Used to reference A String constant, that is, to define the start and end of a string
2.Escape Character to escape the characters (single quotes) that follow it
3. It represents itself, that is, it appears in a String constant as part of a string.
When single quotes with different identities appear together in SQL
The statement is often confusing. Next I will explain how to understand the meaning of each single quotation mark based on my experience and examples.
Conclusion:
1. The meaning of the two single quotes that appear at the beginning and end of the expression must be that a string is referenced to define the start and end of the string.
2. if the single quotation marks appear in the middle of the expression (that is, the single quotation marks starting and ending with a non-expression), and there are no other characters between the multiple single quotation marks, when we analyze from left to right, the first character in the first pair of single quotes is an escape character. It escapes the second single quotes that follow it to make the second single quotes appear as a character in a String constant. Second, third, and so on ......
The following is an example of your experience:
Example 1:
Select ''' from dual;
Result
'
, The expression ''''
The first and fourth single quotes in the expression indicate that a String constant is referenced. The rest of the expression is analyzed from left to right. Because the middle is a pair of single quotes, the first pair is an escape character, it escapes the second one so that the second one represents the single quotation mark itself. The analysis shows that there is a String constant, with only one single quotation mark character. SQL
The statement running result is consistent with our analysis result.
Example 2:
Select
'Exit ''' from dual
Result
Exit''
, Expression'Exit '''''
The first and last single quotes in the clause indicate that a String constant is referenced. The rest of the expression is analyzed from left to right. In the remaining part, the first single quotation mark is followed by a single quotation mark. We use it as a pair. According to Example 1, the parsing result of this pair is a single quotation mark character. Then, we continue to go to the right, we also encounter a pair of single quotes that are next to each other. Similarly, their parsing results are also a single quotes character. The analysis shows that the String constant here contains exit and two single quotes. SQL
The statement running result is consistent with our analysis result.
In ORACLE:
Double quotation marks are used as follows:Object CreationWhen,Object Name and field nameDouble quotation marksOracle will be case sensitiveOtherwise, both of them are capitalized by default.
The single quotation marks indicate that the field with single quotation marks isA word is similar to a string., Not case sensitive.
Single quotes are used to identify the differences between characters and numbers.
When a string text is specified, the string text must be enclosed in single quotes.
Before Oracle10g, if the string text contains single quotes, you must use two single quotes. For example: I'm
A string!
The string text is: string_var: = 'I'm
A string! '
Other delimiters (<>, [], {}, etc.) can be used in Oracle10g. Note that when using these delimiters, you must not only add single quotation marks before and after the delimiters, but also contain the prefix Q. example: string_var: = Q' [I'm
A string!] ';
For example
Select
* From table_name where id = 1; this indicates that the queried number is
Select
* From table_name where id = '1'; this indicates that the query is a character.
Suppose that the double quotation marks are like this. If you have a table field named sysdate, because sysdate is a special character in Oracle, when you want to query this field
Select
"Sysdate" from table_name;
But if you use
Select
'Sysdate' from table_name;
The result is sysdate.
The following update statement cannot be used: Update
Device set dept = 'select * From message where name = 'Tom '';
Handling essentials:
Update
Device set dept = 'select * From message where name = ''tom ''where id = 3 ';
Execution successful.
Originally,Two''
A'
Single quotes in
Oracle has three identities:
1. Used to reference A String constant, that is, to define the start and end of a string
2.Escape Character to escape the characters (single quotes) that follow it
3. It represents itself, that is, it appears in a String constant as part of a string.
When single quotes with different identities appear together in SQL
The statement is often confusing. Next I will explain how to understand the meaning of each single quotation mark based on my experience and examples.
Conclusion:
1. The meaning of the two single quotes that appear at the beginning and end of the expression must be that a string is referenced to define the start and end of the string.
2. if the single quotation marks appear in the middle of the expression (that is, the single quotation marks starting and ending with a non-expression), and there are no other characters between the multiple single quotation marks, when we analyze from left to right, the first character in the first pair of single quotes is an escape character. It escapes the second single quotes that follow it to make the second single quotes appear as a character in a String constant. Second, third, and so on ......
The following is an example of your experience:
Example 1:
Select ''' from dual;
Result
'
, The expression ''''
The first and fourth single quotes in the expression indicate that a String constant is referenced. The rest of the expression is analyzed from left to right. Because the middle is a pair of single quotes, the first pair is an escape character, it escapes the second one so that the second one represents the single quotation mark itself. The analysis shows that there is a String constant, with only one single quotation mark character. SQL
The statement running result is consistent with our analysis result.
Example 2:
Select
'Exit ''' from dual
Result
Exit''
, Expression'Exit '''''
The first and last single quotes in the clause indicate that a String constant is referenced. The rest of the expression is analyzed from left to right. In the remaining part, the first single quotation mark is followed by a single quotation mark. We use it as a pair. According to Example 1, the parsing result of this pair is a single quotation mark character. Then, we continue to go to the right, we also encounter a pair of single quotes that are next to each other. Similarly, their parsing results are also a single quotes character. The analysis shows that the String constant here contains exit and two single quotes. SQL
The statement running result is consistent with our analysis result.