Skip to content

Instantly share code, notes, and snippets.

@joostvanveen
Created March 9, 2018 14:02
Show Gist options
  • Save joostvanveen/8a7e4745bd1f970dc069b760a3501e19 to your computer and use it in GitHub Desktop.
Save joostvanveen/8a7e4745bd1f970dc069b760a3501e19 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