MySQL中單引號和反引號的區別是什嗎?

來源:互聯網
上載者:User
之前在MySQL建表和查詢的時候都用的單引號,後來發現有問題,同學提醒要用反引號,最近發現反引號也會出問題:
1.
2.


在網上看到有說,反引號是為了區分MySQL的保留字和一般字元,這樣的話第2個可以解釋,但是第1個是為什麼呢。
其實單引號和反引號的實際不同是什嗎?MySQL在對這兩個符號的操作是怎樣的?

求解,謝謝。

回複內容:

注意學習。

Certain objects within MySQL, including database, table, index, column, alias, view, stored procedure, partition, tablespace, and other object names are known as identifiers

An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it.

The identifier quote character is the backtick (“`”):

MySQL :: MySQL 5.5 Reference Manual :: 9.2 Schema Object Names

A string is a sequence of bytes or characters, enclosed within either single quote (“'”) or double quote (“"”) characters
MySQL :: MySQL 5.5 Reference Manual :: 9.1.1 String Literals 最簡單的避免錯誤的方法就是,表名等保留字用反引號,其他例如SQL語句用雙引號,我平時就盡量不用單引號的簡單說字串用單引號,表名,欄位名等用反引號
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.