从已有的表创建一个新的空表 CREATE TABLE new_table LIKE old_table; 注意: create table ... like 创建的表会保留原有表的字段.索引的定义,但不会保留外键的定义. 向空表插入数据 INSERT INTO new_table SELECT * FROM old_table; 参考链接:Create table in MySQL that matches another table? - Stack Overflow…
添加字段:alter table matInformation add facid varchar(99) default ''; 导入数据:update matInformation m set facid=(select facid from material_register v where m.partNumber=v.partNumber);(参考:https://blog.csdn.net/mar_fuck/article/details/79460571) 遇到问题:ERROR…
1. 在已存在的表中添加字段约束AUTO_INCREMENT修饰符 mysql> alter table user modify uid int auto_increment primary key; ERROR 1062 (23000): ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY' 理解:uid有0, 而auto_increment是从1开始…