Create table if not exists from mysqldump

前端 未结 8 1123
一整个雨季
一整个雨季 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:18

    The sed will be much faster without the 'g' (global) at its end:

    eg:

    mysqldump -e  | sed 's/^CREATE TABLE /CREATE TABLE IF NOT EXISTS /' > .sql 
    

提交回复
热议问题