1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MySQLのダンプファイルから、特定のテーブルのINSERT文を取り除く

Posted at

目的

MySQLのダンプファイルから、とあるテーブルのINSERT文だけを取り除きたい。

理由

  • 検証環境では利用しないテーブルで、かつそのデータ量(INSERT文)が非常に大きく、インポート時間が長い
  • ダンプの出力そのものには手を入れない

方法

sed を使う。Windows環境でもWSLから使える。

具体例

gzipで圧縮されたMySQLダンプ(db-dump.sql.gz)から、3つのテーブルのINSERT文が書かれている行を除去して、再びgzipで圧縮して別名保存。

gzip -cd "db-dump.sql.gz" | sed -r '/INSERT INTO `(STOCK_C|STOCK_SET|FEE_PATTERN)`/d' | gzip > "./db-dump-sed.sql.gz"
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?