views:

71

answers:

2

i am required to back up certain rows from certain tables from a database. often the criteria requires joins and such. what's a good way to accomplish this? (i don't have to use mysqldump).

A: 

If you are only interested in backing up the data, and don't need to output it as SQL, you can put your select SQL statements into a file and execute those using the mysql command, re-directing to a file like this:

mysql my_database < queries.sql > backup.txt

There are some additional options as far as delimiters and such. Check out the mysql man pages.

jonstjohn
+1  A: 

I would say just backup the entire database. That will be an easier process, and you'll more easily maintain identity integrity in case you need to restore a backup.

orthod0ks