SQL statement 1-set quoted_identifier off

Source: Internet
Author: User

First look at the following SQL statements

Code

1 Set quoted_identifier on
2 select * from "user" where a = 'netasp'
3
4 set quoted_identifier on
5 select * from [user] Where a = 'netasp'
6
7 set quoted_identifier off
8 select * from [user] Where a = "netasp"
9
10 set quoted_identifier off
11 select * from [user] Where a = 'netasp'

When you create a table named "user" in the database, it is often troublesome because the user is a keyword in SQL, but the preceding statements do not report an error. Let's talk about another concept:The identifier is the brackets [] in SQL.

When the set quoted_identifier value is on, the characters in double quotation marks are treated as database objects. That is to say, double quotation marks "" and identifiers [] have the same effect. They all indicate that the referenced characters are database objects. Single quotation marks (') indicate the boundary of a string.

When set quotde_identifier off, double quotation marks are interpreted as string boundary, which is similar to single quotation marks. Double quotation marks cannot be used as identifiers, but can be used as character boundary. They have the same effect as single quotation marks.

A summary can be made: When set quoted_identifier on "" is equivalent to [], it indicates the database object; when set quoted_identifier off "" is equivalent to '', it indicates the string boundary; the double quotation marks here are not combined by two single quotation marks. They are produced by SHIFT +. Beginners may make such mistakes.

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.