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

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

      1. <legend id='fvTsW'><style id='fvTsW'><dir id='fvTsW'><q id='fvTsW'></q></dir></style></legend>
      2. 如何转义用作列名的保留字?MySQL/创建表

        时间:2023-08-20
      3. <legend id='OimyX'><style id='OimyX'><dir id='OimyX'><q id='OimyX'></q></dir></style></legend>

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

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

              <tbody id='OimyX'></tbody>
                <bdo id='OimyX'></bdo><ul id='OimyX'></ul>
                <tfoot id='OimyX'></tfoot>
                • 本文介绍了如何转义用作列名的保留字?MySQL/创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在从 .NET 中的类生成表,一个问题是一个类可能有一个字段名称 key,这是一个保留的 MySQL 关键字.如何在 create table 语句中转义它?(注意:下面的另一个问题是文本必须是固定大小才能被索引/唯一)

                  I am generating tables from classes in .NET and one problem is a class may have a field name key which is a reserved MySQL keyword. How do I escape it in a create table statement? (Note: The other problem below is text must be a fixed size to be indexed/unique)

                  create table if not exists misc_info (
                  id INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
                  key TEXT UNIQUE NOT NULL,
                  value TEXT NOT NULL)ENGINE=INNODB;
                  

                  推荐答案

                  如果 ANSI SQL 模式 已启用

                  CREATE TABLE IF NOT EXISTS misc_info
                    (
                       id    INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
                       "key" TEXT UNIQUE NOT NULL,
                       value TEXT NOT NULL
                    )
                  ENGINE=INNODB; 
                  

                  或以其他方式转义的专有反勾号.(这个答案中介绍了在各种键盘布局上哪里可以找到 ` 字符)>

                  or the proprietary back tick escaping otherwise. (Where to find the ` character on various keyboard layouts is covered in this answer)

                  CREATE TABLE IF NOT EXISTS misc_info
                    (
                       id    INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
                       `key` TEXT UNIQUE NOT NULL,
                       value TEXT NOT NULL
                    )
                  ENGINE=INNODB; 
                  

                  (来源:MySQL 参考手册,9.3 保留字)

                  这篇关于如何转义用作列名的保留字?MySQL/创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:获取两个日期之间的日期列表 下一篇:MySQL参数化查询

                  相关文章

                  最新文章

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

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

                • <tfoot id='fxY9P'></tfoot>

                    <bdo id='fxY9P'></bdo><ul id='fxY9P'></ul>

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