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

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

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

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

        <tfoot id='AD4d8'></tfoot>

        MySQL:ALTER IGNORE TABLE ADD UNIQUE,什么会被截断?

        时间:2023-05-31

          1. <tfoot id='Ipd7i'></tfoot>
            <legend id='Ipd7i'><style id='Ipd7i'><dir id='Ipd7i'><q id='Ipd7i'></q></dir></style></legend>

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

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

                  本文介绍了MySQL:ALTER IGNORE TABLE ADD UNIQUE,什么会被截断?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含 4 列的表格:ID、类型、所有者、描述.ID 是 AUTO_INCREMENT PRIMARY KEY,现在我想:

                  I have a table with 4 columns: ID, type, owner, description. ID is AUTO_INCREMENT PRIMARY KEY and now I want to:

                  ALTER IGNORE TABLE `my_table`
                      ADD UNIQUE (`type`, `owner`);
                  

                  当然,我很少有 type = 'Apple' 和 owner = 'Apple CO' 的记录.所以我的问题是,哪条记录将是那个 ALTER TABLE 之后要保留的特殊记录,是 ID 最小的记录还是最新插入的 ID 最大的记录?

                  Of course I have few records with type = 'Apple' and owner = 'Apple CO'. So my question is which record will be the special one to stay after that ALTER TABLE, the one with smallest ID or maybe the one with biggest as the latest inserted?

                  推荐答案

                  第一条记录会保留,其余删除§§:

                  The first record will be kept, the rest deleted §§:

                  IGNORE 是 MySQL 的扩展标准 SQL.它控制如何改变如果存在重复项,则 TABLE 有效新表中的唯一键或者如果使用严格模式时会出现警告启用.如果未指定 IGNORE,副本被中止并回滚,如果发生重复键错误.如果 IGNORE指定,只有第一行使用在 a 上有重复的行唯一键,其他冲突行被删除.不正确的值是截断到最接近的匹配可接受值

                  IGNORE is a MySQL extension to standard SQL. It controls how ALTER TABLE works if there are duplicates on unique keys in the new table or if warnings occur when strict mode is enabled. If IGNORE is not specified, the copy is aborted and rolled back if duplicate-key errors occur. If IGNORE is specified, only the first row is used of rows with duplicates on a unique key, The other conflicting rows are deleted. Incorrect values are truncated to the closest matching acceptable value

                  我猜这里的第一个"是指 ID 最小的那个,假设 ID 是主键.

                  I am guessing 'first' here means the one with the smallest ID, assuming the ID is the primary key.

                  另请注意:

                  从 MySQL 5.7.4 开始,ALTER TABLEIGNORE 子句被删除,它的使用会产生一个错误强>.

                  As of MySQL 5.7.4, the IGNORE clause for ALTER TABLE is removed and its use produces an error.

                  这篇关于MySQL:ALTER IGNORE TABLE ADD UNIQUE,什么会被截断?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在MySQL数据库中插入文件? 下一篇:找不到“MySql.Data.MySqlClient"ADO.NET 提供程序的实体框架提供程序

                  相关文章

                  <tfoot id='LPGZR'></tfoot>
                  <legend id='LPGZR'><style id='LPGZR'><dir id='LPGZR'><q id='LPGZR'></q></dir></style></legend>
                1. <small id='LPGZR'></small><noframes id='LPGZR'>

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

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