Suppose I have database A and Table b. Given multiple .sql files b1,b2,...,bn each of which corresponds to a mutually exclusive table dump of b how would I go about combining all files b1,b2,...,bn into a single .sql table file? Or how would I combine the import of the individual files into a single table?
Click Export. In the File format section, click SQL to create a SQL dump file. In the Data to export section, click One or more databases in this instance to export specific databases. Use the drop-down menu to select the databases you want to export from.
Import Multiple SQL files to Database by using Data Import/Restore in MySQL Workbench is great feature when you need to import multiple SQL files into MySQL Server. If you have created multiple files by using Data Export feature in MySQL Server, SQL Dump file project can be imported by using MySQL Import/Restore.
From there, CTRL+V into an SSMS window. It works with multiple files too. Select two or more files in Explorer, right-click any of the highlighted files, and select "Copy as path". Repeat steps in SSMS.
There are no special tools to do this. You can simply concatenate the files:
$ cat b1.sql b2.sql b3.sql > b_all.sql
Except that the typical content of these .sql files is a DROP TABLE, then a CREATE TABLE, then a lot of INSERT statements. If each of the individual dump files is formatted like that, then if you restore them in sequence, each will DROP TABLE and erase the data imported by the preceding file.
You can create a dump file without the DROP/CREATE statements:
$ mysqldump --no-create-info <database> <table> ...
But if you have the dump files already (can't re-dump them), and you want to get rid of the DROP/CREATE statements in all but the first file:
$ ( cat b1.sql ; cat b2.sql b3.sql | sed -e '/^DROP TABLE/,/^-- Dumping data/d' ) > b_all.sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With