MySQL split dump to table

Hello,

From my last post: MySQL split dump to different databases

from last year, today I will share how quickly and easily we can extract a dump table from our MySQL database. Of course, if we our database a small one, we can open this dump and copy the content of the table into a text editor, but when our base is 100GB it will not be possible.

 

Everything is thanks to sed  :

sed -n -e '/CREATE TABLE.*`fc_company`/,/CREATE TABLE/p' 201709140001-db-CRM.sql > fc_company.sql

Here things seems to be quite clear, but I will clear them out:

  1. fc_company is the table which we want to get
  2. 201709140001-db-CRM.sql is the name of our dump
  3. fc_company.sql is the name of the new dump with our table

It is goot to check the fc_company.sql file, because sed gets the beggining of the next table and drops it 🙂 An example is if we have table fc_compay_new for example.

That’s it!