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

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

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

    3. 如何向 MySQL 表添加主键?

      How to add a primary key to a MySQL table?(如何向 MySQL 表添加主键?)

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

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

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

              1. <tfoot id='kIJZP'></tfoot>
                本文介绍了如何向 MySQL 表添加主键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是我尝试过但失败的方法:

                This is what I tried but it fails:

                alter table goods add column `id` int(10) unsigned primary AUTO_INCREMENT;
                

                有人给个提示吗?

                推荐答案

                添加列后,可以随时添加主键:

                After adding the column, you can always add the primary key:

                ALTER TABLE 商品ADD PRIMARY KEY(id)

                至于为什么你的脚本不起作用,你需要指定PRIMARY KEY,而不仅仅是PRIMARY这个词:

                As to why your script wasn't working, you need to specify PRIMARY KEY, not just the word PRIMARY:

                alter table goods add column `id` int(10) unsigned primary KEY AUTO_INCREMENT;
                

                这篇关于如何向 MySQL 表添加主键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to delete duplicate records in mysql database?(如何删除mysql数据库中的重复记录?)
                Python Pandas write to sql with NaN values(Python Pandas 使用 NaN 值写入 sql)
                MySQL Insert amp; Joins(MySQL 插入 amp;加入)
                MySQL concat() to create column names to be used in a query?(MySQL concat() 创建要在查询中使用的列名?)
                NodeJS responded MySQL timezone is different when I fetch directly from MySQL(当我直接从 MySQL 获取时,NodeJS 响应 MySQL 时区不同)
                WHERE datetime older than some time (eg. 15 minutes)(WHERE 日期时间早于某个时间(例如 15 分钟))
                  <tfoot id='PM0x4'></tfoot>

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

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