如何将SQL转储导入表而不覆盖重复字段

如何将SQL转储导入表而不覆盖重复字段

本文介绍了如何将SQL转储导入表而不覆盖重复字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将MySQL转储文件导入数据库而不覆盖具有相同值的记录?

how do I import a MySQL dump file to a database without overwriting records with the same value?

推荐答案

到手册。您可以指定是否替换现有记录。

Here is the link to the manual. You can specify whether to replace existing records.

--replace, -r

- replace - 忽略 options控制对唯一键值上的现有行进行重复的输入行的处理。如果指定 - replace ,新行将替换具有相同唯一键值的现有行。如果指定 - ignore ,则会跳过在唯一键值上复制现有行的输入行。如果不指定任何选项,则会在找到重复键值时发生错误,并忽略文本文件的其余部分。

The --replace and --ignore options control handling of input rows that duplicate existing rows on unique key values. If you specify --replace, new rows replace existing rows that have the same unique key value. If you specify --ignore, input rows that duplicate an existing row on a unique key value are skipped. If you do not specify either option, an error occurs when a duplicate key value is found, and the rest of the text file is ignored.

如果您正在使用phpmyadmin,那么您也将在GUI中拥有此选项。

If you are using phpmyadmin then you will have an option for this in the GUI as well.

这篇关于如何将SQL转储导入表而不覆盖重复字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 00:10