How do I delete a table from a mysqldump

后端 未结 3 767
无人共我
无人共我 2021-02-04 17:02

How do I delete the output for one big table inside a mysqldump with lots of tables in it?

I have a dump of a database that is 6 GB large, but 90% of it is only one logg

3条回答
  •  温柔的废话
    2021-02-04 17:38

    you need to find the create table statement of your table, and find the next create table statement. say they are n1 and n2.

    then you can just delete them with sed as above. sed 'n1,n2d' dump.sql > new.sql

    you can just grep create table and note the line numbers for your prework.

    here is a demo.

    ubuntu@ubuntu:~$ grep -n [34] a.txt
    3:3
    4:4
    ubuntu@ubuntu:~$ cat a.txt
    1
    2
    3
    4
    5
    6
    ubuntu@ubuntu:~$ grep [34] a.txt
    3
    4
    ubuntu@ubuntu:~$ sed '3,4d' a.txt > b.txt
    ubuntu@ubuntu:~$ cat b.txt
    1
    2
    5
    6
    ubuntu@ubuntu:~$ 
    

提交回复
热议问题