问题描述
如何指示mysqldump在插入语句中使用列名进行备份?
就我而言,插入sql不会导致
How do I instruct mysqldump to backup with column names in insert statements?
In my case I didn’t a normal back up with insert sql’s resulting in
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users`
INSERT INTO `users` VALUES (1
结构.
现在,我继续进行操作,并从用户的架构中删除了一个列.之后,当我运行备用sql时,出现列号不匹配错误.
Now I went ahead and removed a column from the schema in users. After this when I run the backup sql’s I get a column number mismatch error.
要解决此问题,我该如何指示mysqldump也写列名?这就是我现在的做法
To fix this how do I go about instructing mysqldump to write column names too?Here is how I do it now
mysqldump --host=${dbserver} --user=${dbusername} --password=${dbpassword} \
--no-create-db --no-create-info --extended-insert --single-transaction \
--compress tablename
从广义上讲,管理这些架构更改的最佳实践是什么?
On a broader level, what’s the best practice to manage these schema changes?
推荐答案
在mysqldump命令参数中使用--complete-insert
Use --complete-insert
in the mysqldump command params
这篇关于Mysqldump:在备份时为插入创建列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!