• <bdo id='n3lJC'></bdo><ul id='n3lJC'></ul>

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

        ALTER 表 - 在 MySQL 中添加 AUTOINCREMENT

        ALTER table - adding AUTOINCREMENT in MySQL(ALTER 表 - 在 MySQL 中添加 AUTOINCREMENT)
        • <bdo id='WXmTX'></bdo><ul id='WXmTX'></ul>

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

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

                <tfoot id='WXmTX'></tfoot>
                <legend id='WXmTX'><style id='WXmTX'><dir id='WXmTX'><q id='WXmTX'></q></dir></style></legend>

                  本文介绍了ALTER 表 - 在 MySQL 中添加 AUTOINCREMENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 MySQL 中用 itemID 列创建了一个表.

                  I created a table in MySQL with on column itemID.

                  创建表格后,现在我想将此列更改为AUTOINCREMENT.

                  After creating the table, now I want to change this column to AUTOINCREMENT.

                  如何使用 ALTER 语句完成此操作?

                  表定义:

                  ALLITEMS (itemid int(10) unsigned, itemname varchar(50))

                  我正在使用以下代码,但它引发了语法错误

                  I am using the following code but it is throwing a syntax error

                  错误:语法不正确.

                  ALTER TABLE allitems
                  MODIFY itemid INT(10) UNSIGNED AUTOINCREMENT; 
                  

                  推荐答案

                  CREATE TABLE ALLITEMS(
                      itemid INT(10)UNSIGNED,
                      itemname VARCHAR(50)
                  );
                  
                  ALTER TABLE ALLITEMS CHANGE itemid itemid INT(10)AUTO_INCREMENT PRIMARY KEY;
                  
                  DESC ALLITEMS;
                  
                  INSERT INTO ALLITEMS(itemname)
                  VALUES
                      ('Apple'),
                      ('Orange'),
                      ('Banana');
                  
                  SELECT
                      *
                  FROM
                      ALLITEMS;
                  

                  我之前也对 CHANGEMODIFY 关键字感到困惑:

                  I was confused with CHANGE and MODIFY keywords before too:

                  ALTER TABLE ALLITEMS CHANGE itemid itemid INT(10)AUTO_INCREMENT PRIMARY KEY;
                  
                  ALTER TABLE ALLITEMS MODIFY itemid INT(5);
                  

                  当我们在那里时,还要注意 AUTO_INCREMENT 也可以以预定义的数字开头:

                  While we are there, also note that AUTO_INCREMENT can also start with a predefined number:

                  ALTER TABLE tbl AUTO_INCREMENT = 100;
                  

                  这篇关于ALTER 表 - 在 MySQL 中添加 AUTOINCREMENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                  <tfoot id='SDN8B'></tfoot>

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

                      • <bdo id='SDN8B'></bdo><ul id='SDN8B'></ul>
                          <tbody id='SDN8B'></tbody>
                      • <legend id='SDN8B'><style id='SDN8B'><dir id='SDN8B'><q id='SDN8B'></q></dir></style></legend>

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