Portal Home > Knowledgebase > Articles Database > mysql dump only certain tables
mysql dump only certain tables
Posted by Markovic, 05-31-2010, 05:26 AM |
Hey
I have a BIG table in my vBulletin database. I want to delete most of it. Basically I want to dump only columns with forum_id=1 and forum_id=2 from the posts table and delete everything else. Normally it would take too long to delete everything so I thought there is a way to dump only columns which has forum_id=1 and forum_id=2
Thanks a lot
|
Posted by madaboutlinux, 05-31-2010, 05:52 AM |
Yes, --where option should help you in dumping specific rows of a table.
Say for example, you have a database called "dbtest" and a table called "tbltest" with 10 rows in it having a ID field and you want to dump only the rows having ID from 5-10.
The following should help you in achieving it
A backup with expected result will be saved in tbltest.sql file.
|
Posted by Markovic, 05-31-2010, 06:03 AM |
Hey,
That helps. How can I dump columns with id's 1, 2 and 3.
Would that work?
mysqldump dbtest tbltest --where "ID=1,2,3" > tbltest.sql
or
mysqldump dbtest tbltest --where "ID=1,ID=2,ID=3" > tbltest.sql
?
|
Posted by madaboutlinux, 05-31-2010, 06:13 AM |
Unfortunately, there doesn't seem to be any such option.
|
Posted by adminpaul, 05-31-2010, 06:36 AM |
Hi,
Try this.
mysqldump dbtest tbltest --where "ID=1 or ID=2 or ID=3" > tbltest.sql
|
Add to Favourites Print this Article
Also Read