【问题标题】:I can't insert a lots of rows to column in a table with other auto_increment column.我无法在具有其他 auto_increment 列的表中插入大量行。
【发布时间】:2018-12-01 03:06:14
【问题描述】:

我有一个带有 auto_increment ID 列的表,我想添加另一列,它会从 ID 列复制数字(例如命名为copyed_ID),所以我 想要两个相同的 colmun,其中一个是 auto_increment。 before_photo 我试过了:

insert into my_table (copied_ID) select ID from my_table;

但是我得到了: after_photo

【问题讨论】:

    标签: mysql sql insert-into


    【解决方案1】:

    如果要添加另一列:

    -- Add the column to the table, if necessary
    alter table my_table add column copied_id int; 
    
    -- Update the table
    update my_table 
        set copied_id = id;
    

    insert 插入新的。您想添加一个新的

    【讨论】:

      猜你喜欢
      • 2023-01-01
      • 2010-12-04
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 2017-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多