The difference between anti-quotes and single quotes in MySQL

Source: Internet
Author: User
Tags reserved

Anti-quotes, usually below the ESC key.

It is a symbol that is introduced to differentiate between MySQL's reserved words and ordinary characters.
For example: Select ' Select ' From ' Test ' WHERE select= ' field value '
In the test table, there is a select field, without the use of anti-quotes, MySQL will treat select as a reserved word resulting in an error, so there is a MySQL reserved word as a field, you must add the anti-quote to distinguish.

Quotation marks are generally used in the value of the field, and if the field value is a character or string, enclose it in quotation marks, such as: select= ' field value '
Tables built without anti-quotes cannot contain mysql reserved words, otherwise an error occurs
With normal quotes, when you enter an opening quotation mark, the content that is enclosed in normal quotation marks is green because the quotation marks are not closed and the contents are quoted as default.

When we build a table, we generally use the table name, the library names, and the counter-quotes to guarantee the execution of the statement. Anti-quote ', number 1 to the left of the symbol.
Reserved words cannot be used for table names, such as DESC, which need to be added in reverse quotation marks, but can be ignored when using table names.
CREATE TABLE desc Error
CREATE TABLE ' desc ' success
CREATE TABLE ' test ' succeeded
DROP table Test Succeeded
Reserved words cannot be used for field names, such as Desc, where you also need to add anti-quotes, and insert and so on with an anti-quote.
CREATE TABLE ' Test ' (' desc ' varchar (255)) succeeded
INSERT INTO Test (DESC) VALUES (' FXF ') failed
INSERT INTO Test (' desc ') VALUES (' FXF ') succeeded

The difference between anti-quotes and single quotes in MySQL

Related Article

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.