简体   繁体   English

如何更新已经存在的mysql表

[英]how to update mysql table Which already exists

I have a database with hundreds of tables I bring just an example this is my database That's how it looks : my table call stuff That is how the table looks 我有一个包含数百个表的数据库,我仅举一个例子,这就是我的数据库,它的样子是:我的表调用的东西,这就是表的样子

id name

1  001

2  002

3  003

Now I have an update that I just want to update After table 3 Because a different computer is created not the server 现在我有了一个更新,我只想更新表3之后,因为创建了另一台计算机而不是服务器

INSERT INTO `stuff` VALUES (1, '004');
INSERT INTO `stuff` VALUES (2, '005');

I currently have 2 backups 我目前有2个备份

stuff1.sql AND stuff2.sql stuff1.sql和stuff2.sql

My question is with a possible update table without starting to number it in order 我的问题是有可能的更新表,而没有开始按顺序编号

I could have done it like this : 我本可以这样做:

INSERT INTO `stuff` VALUES (1, '001');
INSERT INTO `stuff` VALUES (2, '002');
INSERT INTO `stuff` VALUES (3, '003');
INSERT INTO `stuff` VALUES (4, '004');
INSERT INTO `stuff` VALUES (5, '005');

But what do you do when there are many tables? 但是,如果有很多桌子,您该怎么办?

Use id as auto increment and do this 使用id作为自动增量并执行此操作

INSERT INTO `stuff` (`name`) VALUES ('001');

and now it insert row with next id. 现在,它插入具有下一个ID的行。

Hope this help. 希望能有所帮助。

try to write this in 'DDL' before insert the data : 尝试在插入数据之前将其写入“ DDL”:

[column_name] Integer- primary key - autoincremen , [column_name]整数-主键-自动递增,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM