Skip to content

Instantly share code, notes, and snippets.

@phillipwilhelm
Forked from joostvanveen/csplit.sh
Created April 1, 2020 04:31
Show Gist options
  • Save phillipwilhelm/d2145f16c8b0a49703f11a11fe940f27 to your computer and use it in GitHub Desktop.
Save phillipwilhelm/d2145f16c8b0a49703f11a11fe940f27 to your computer and use it in GitHub Desktop.
Split large SQL files into separate files for each table
## Split large SQL files into separate files for each table if every tabel starts with a 'DROP TABLE IF EXISTS' statement
csplit -k $PWD/filename.sql '/^DROP TABLE IF EXISTS .*/' '{900}'
## Split large SQL files into separate files for each table if every tabel starts with a 'CREATE TABLE' statement
csplit -k $PWD/filename.sql '/^CREATE TABLE .*/' '{900}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment