Use of single quotes and double quotes in OracleSQL statements

Source: Internet
Author: User
** In Oracle, double quotation marks are treated as a normal string. ** SELECT

/** In Oracle, double quotation marks are treated as a normal string. **/SELECT

/** Double quotation marks in Oracle "are treated as a normal string **/
/** Test the condition of the three single quotes: ORA-01756: The character strings in the quotation marks do not end properly **/
SELECT ''' from dual;
/** Test the four single quotes: The result is a '(single quotes )**/
-- The second single quotation mark is considered as an escape character by ORACLE by default.
SELECT ''' from dual;
/** Verify that the second single quotation mark is the inference of escape characters, and add a space between the second and third single quotation marks **/
-- Error prompt: ORA-0092: the requested FROM keyword is not found to indicate that the inference is correct
SELECT ''' from dual;
/** Single quotes are often used in dynamic SQL. For example, you need to dynamically add like and write a small test example **/
DECLARE
V_ SQL VARCHAR2 (200 );
N_COUNT NUMBER (4 );
V_NAME VARCHAR2 (100 );
BEGIN
V_NAME: = 'name ';
V_ SQL: = 'select COUNT (1) FROM T1 WHERE 1 = 1 ';
V_ SQL: = CONCAT (V_ SQL, 'AND T1.NAME LIKE' % '| V_NAME |' % ''');
Execute immediate V_ SQL INTO N_COUNT;
DBMS_OUTPUT.PUT_LINE ('n' _ COUNT '|' => '| N_COUNT );
END;


/** Summary:
1. in ORACLE, double quotation marks are processed as common strings.
2. In a single pair of quotes, a pair of adjacent single quotes must be included to indicate a single quotation mark.
3. Two adjacent single quotes. The first one is used to indicate escape characters, and the last one is used to indicate true 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.