Create table if not exists from mysqldump

前端 未结 8 1195
一整个雨季
一整个雨季 2020-12-29 21:35

I\'m wondering if there is any way in mysqldump to add the appropriate create table option [IF NOT EXISTS]. Any ideas?

8条回答
  •  余生分开走
    2020-12-29 22:15

    According to one source, mysqldump does not feature this option.

    You could use the --force option when importing the dump file back, where MySQL will ignore the errors generated from attempts to create duplicate tables. However note that with this method, other errors would be ignored as well.

    Otherwise, you can run your dump file through a script that would replace all occurrences of CREATE TABLE with CREATE TABLE IF NOT EXISTS.

提交回复
热议问题