久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='yJNA9'><tr id='yJNA9'><dt id='yJNA9'><q id='yJNA9'><span id='yJNA9'><b id='yJNA9'><form id='yJNA9'><ins id='yJNA9'></ins><ul id='yJNA9'></ul><sub id='yJNA9'></sub></form><legend id='yJNA9'></legend><bdo id='yJNA9'><pre id='yJNA9'><center id='yJNA9'></center></pre></bdo></b><th id='yJNA9'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yJNA9'><tfoot id='yJNA9'></tfoot><dl id='yJNA9'><fieldset id='yJNA9'></fieldset></dl></div>
      • <bdo id='yJNA9'></bdo><ul id='yJNA9'></ul>

        <legend id='yJNA9'><style id='yJNA9'><dir id='yJNA9'><q id='yJNA9'></q></dir></style></legend>

        <small id='yJNA9'></small><noframes id='yJNA9'>

        <tfoot id='yJNA9'></tfoot>

        由于在 MySQL 中使用保留字作為表名或列名導(dǎo)致的

        Syntax error due to using a reserved word as a table or column name in MySQL(由于在 MySQL 中使用保留字作為表名或列名導(dǎo)致的語(yǔ)法錯(cuò)誤)
      1. <small id='FKRYK'></small><noframes id='FKRYK'>

        <i id='FKRYK'><tr id='FKRYK'><dt id='FKRYK'><q id='FKRYK'><span id='FKRYK'><b id='FKRYK'><form id='FKRYK'><ins id='FKRYK'></ins><ul id='FKRYK'></ul><sub id='FKRYK'></sub></form><legend id='FKRYK'></legend><bdo id='FKRYK'><pre id='FKRYK'><center id='FKRYK'></center></pre></bdo></b><th id='FKRYK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FKRYK'><tfoot id='FKRYK'></tfoot><dl id='FKRYK'><fieldset id='FKRYK'></fieldset></dl></div>
        <tfoot id='FKRYK'></tfoot>
          • <bdo id='FKRYK'></bdo><ul id='FKRYK'></ul>
                <tbody id='FKRYK'></tbody>
              <legend id='FKRYK'><style id='FKRYK'><dir id='FKRYK'><q id='FKRYK'></q></dir></style></legend>

                  本文介紹了由于在 MySQL 中使用保留字作為表名或列名導(dǎo)致的語(yǔ)法錯(cuò)誤的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在嘗試執(zhí)行一個(gè)簡(jiǎn)單的 MySQL 查詢,如下所示:

                  I'm trying to execute a simple MySQL query as below:

                  INSERT INTO user_details (username, location, key)
                  VALUES ('Tim', 'Florida', 42)
                  

                  但我收到以下錯(cuò)誤:

                  ERROR 1064 (42000):您的 SQL 語(yǔ)法有錯(cuò)誤;檢查與您的 MySQL 服務(wù)器版本相對(duì)應(yīng)的手冊(cè),了解在第 1 行的 'key) VALUES ('Tim', 'Florida', 42)' 附近使用的正確語(yǔ)法

                  ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key) VALUES ('Tim', 'Florida', 42)' at line 1

                  我該如何解決這個(gè)問(wèn)題?

                  How can I fix the issue?

                  推薦答案

                  問(wèn)題

                  在 MySQL 中,SELECTINSERTDELETE 等某些詞是保留字.由于它們具有特殊含義,因此每當(dāng)您將它們用作表名、列名或其他類型的標(biāo)識(shí)符時(shí),MySQL 都會(huì)將其視為語(yǔ)法錯(cuò)誤 - 除非您用反引號(hào)將標(biāo)識(shí)符括起來(lái).

                  The Problem

                  In MySQL, certain words like SELECT, INSERT, DELETE etc. are reserved words. Since they have a special meaning, MySQL treats it as a syntax error whenever you use them as a table name, column name, or other kind of identifier - unless you surround the identifier with backticks.

                  如官方文檔中所述,在10.2 Schema Object Names(強(qiáng)調(diào)):

                  As noted in the official docs, in section 10.2 Schema Object Names (emphasis added):

                  MySQL 中的某些對(duì)象,包括數(shù)據(jù)庫(kù)、表、索引、列、別名、視圖、存儲(chǔ)過(guò)程、分區(qū)、表空間和其他對(duì)象名稱被稱為標(biāo)識(shí)符.

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

                  ...

                  如果標(biāo)識(shí)符包含特殊字符或者是保留字,則在引用它時(shí)必須引用它.

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

                  ...

                  標(biāo)識(shí)符引號(hào)字符是反引號(hào)(`"):

                  The identifier quote character is the backtick ("`"):

                  完整的關(guān)鍵字和保留字列表可以在10.3 關(guān)鍵字部分找到和保留字.在該頁(yè)面中,后跟(R)"的單詞是是保留字.下面列出了一些保留字,包括許多容易導(dǎo)致此問(wèn)題的字.

                  A complete list of keywords and reserved words can be found in section 10.3 Keywords and Reserved Words. In that page, words followed by "(R)" are reserved words. Some reserved words are listed below, including many that tend to cause this issue.

                  • 添加
                  • AND
                  • 之前
                  • 打電話
                  • 案例
                  • 條件
                  • 刪除
                  • DESC
                  • 描述
                  • 來(lái)自
                  • 進(jìn)入
                  • 索引
                  • 插入
                  • 間隔
                  • 密鑰
                  • 喜歡
                  • 限制
                  • 長(zhǎng)
                  • 匹配
                  • 不是
                  • 選項(xiàng)
                  • 訂購(gòu)
                  • 分區(qū)
                  • 排名
                  • 參考文獻(xiàn)
                  • 選擇
                  • 表格
                  • 更新
                  • 哪里

                  你有兩個(gè)選擇.

                  最簡(jiǎn)單的解決方案就是避免使用保留字作為標(biāo)識(shí)符.您可能會(huì)為您的列找到另一個(gè)非保留字的合理名稱.

                  The simplest solution is simply to avoid using reserved words as identifiers. You can probably find another reasonable name for your column that is not a reserved word.

                  這樣做有幾個(gè)好處:

                  • 它消除了您或使用您的數(shù)據(jù)庫(kù)的其他開(kāi)發(fā)人員由于忘記 - 或不知道 - 特定標(biāo)識(shí)符是保留字而意外寫入語(yǔ)法錯(cuò)誤的可能性.MySQL 中有很多保留字,大多數(shù)開(kāi)發(fā)人員不太可能知道所有這些.一開(kāi)始就不要使用這些詞,可以避免給自己或未來(lái)的開(kāi)發(fā)人員留下陷阱.

                  • It eliminates the possibility that you or another developer using your database will accidentally write a syntax error due to forgetting - or not knowing - that a particular identifier is a reserved word. There are many reserved words in MySQL and most developers are unlikely to know all of them. By not using these words in the first place, you avoid leaving traps for yourself or future developers.

                  引用標(biāo)識(shí)符的方式因 SQL 方言而異.雖然 MySQL 默認(rèn)使用反引號(hào)來(lái)引用標(biāo)識(shí)符,但符合 ANSI 標(biāo)準(zhǔn)的 SQL(實(shí)際上是 ANSI SQL 模式下的 MySQL,如此處所述) 使用雙引號(hào)來(lái)引用標(biāo)識(shí)符.因此,使用反引號(hào)引用標(biāo)識(shí)符的查詢不太容易移植到其他 SQL 方言中.

                  The means of quoting identifiers differs between SQL dialects. While MySQL uses backticks for quoting identifiers by default, ANSI-compliant SQL (and indeed MySQL in ANSI SQL mode, as noted here) uses double quotes for quoting identifiers. As such, queries that quote identifiers with backticks are less easily portable to other SQL dialects.

                  純粹是為了降低未來(lái)出錯(cuò)的風(fēng)險(xiǎn),這通常比反引號(hào)標(biāo)識(shí)符更明智.

                  Purely for the sake of reducing the risk of future mistakes, this is usually a wiser course of action than backtick-quoting the identifier.

                  如果無(wú)法重命名表或列,請(qǐng)將有問(wèn)題的標(biāo)識(shí)符用反引號(hào) (`) 括起來(lái),如 10.2 架構(gòu)對(duì)象名稱.

                  If renaming the table or column isn't possible, wrap the offending identifier in backticks (`) as described in the earlier quote from 10.2 Schema Object Names.

                  演示用法的示例(取自10.3 關(guān)鍵字和保留字):

                  An example to demonstrate the usage (taken from 10.3 Keywords and Reserved Words):

                  mysql> CREATE TABLE interval (begin INT, end INT);
                  ERROR 1064 (42000): You have an error in your SQL syntax.
                  near 'interval (begin INT, end INT)'
                  

                  mysql> CREATE TABLE `interval` (begin INT, end INT); Query OK, 0 rows affected (0.01 sec)

                  同樣,可以通過(guò)將關(guān)鍵字key包裹在反引號(hào)中來(lái)修復(fù)來(lái)自問(wèn)題的查詢,如下所示:

                  Similarly, the query from the question can be fixed by wrapping the keyword key in backticks, as shown below:

                  INSERT INTO user_details (username, location, `key`)
                  VALUES ('Tim', 'Florida', 42)";               ^   ^
                  

                  這篇關(guān)于由于在 MySQL 中使用保留字作為表名或列名導(dǎo)致的語(yǔ)法錯(cuò)誤的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數(shù)根據(jù) N 個(gè)先前值來(lái)決定接下來(lái)的 N 個(gè)行)
                  reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達(dá)式的結(jié)果;條款?)
                  Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數(shù)的 ignore 選項(xiàng)是忽略整個(gè)事務(wù)還是只是有問(wèn)題的行?) - IT屋-程序員軟件開(kāi)發(fā)技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時(shí)出錯(cuò),使用 for 循環(huán)數(shù)組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調(diào)用 o23.load 時(shí)發(fā)生錯(cuò)誤 沒(méi)有合適的驅(qū)動(dòng)程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數(shù)據(jù)庫(kù)表作為 Spark 數(shù)據(jù)幀讀取?)
                1. <i id='TzYb5'><tr id='TzYb5'><dt id='TzYb5'><q id='TzYb5'><span id='TzYb5'><b id='TzYb5'><form id='TzYb5'><ins id='TzYb5'></ins><ul id='TzYb5'></ul><sub id='TzYb5'></sub></form><legend id='TzYb5'></legend><bdo id='TzYb5'><pre id='TzYb5'><center id='TzYb5'></center></pre></bdo></b><th id='TzYb5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TzYb5'><tfoot id='TzYb5'></tfoot><dl id='TzYb5'><fieldset id='TzYb5'></fieldset></dl></div>
                    <tbody id='TzYb5'></tbody>

                    <bdo id='TzYb5'></bdo><ul id='TzYb5'></ul>
                      <tfoot id='TzYb5'></tfoot>

                        1. <small id='TzYb5'></small><noframes id='TzYb5'>

                          <legend id='TzYb5'><style id='TzYb5'><dir id='TzYb5'><q id='TzYb5'></q></dir></style></legend>

                            主站蜘蛛池模板: 99国产视频 | 麻豆视频在线免费观看 | 九七午夜剧场福利写真 | 亚洲精品乱码久久久久久按摩观 | www日日日| 久久精品av | 日韩午夜影院 | 成人不卡视频 | 免费播放一级片 | 国产精品久久国产愉拍 | 日韩靠逼 | 二区三区在线观看 | 午夜性色a√在线视频观看9 | 欧美一区二区在线播放 | 国产视频久久久久 | 国产原创在线观看 | 欧美精品一区在线发布 | 中文在线播放 | 中文字幕欧美日韩一区 | 一区二区久久精品 | 在线视频 亚洲 | 观看av| 国产一区二区在线播放视频 | 色眯眯视频在线观看 | 超碰人人插 | 日韩欧美一级精品久久 | 亚洲精品视频在线看 | 成人在线免费网站 | 国产激情视频在线免费观看 | 欧美久久一区二区 | a网站在线观看 | 看亚洲a级一级毛片 | 亚洲成人动漫在线观看 | 国产欧美日韩一区二区三区在线观看 | 日韩欧美在线一区 | 久久久久久久久91 | 黄网站在线播放 | 一级片在线视频 | 久久久久久久久蜜桃 | 欧美日韩国产一区 | 国产在线97 |