i like to create a backup script in java which will backup a table but only some selected rows. Please see this example table:
table names:
id, group, name
1, 1, "John"
2, 1, "Frank"
3, 1, "Smith"
4, 2, "Anny"
5, 2, "Gustav"
table ages:
id, group, age
1, 1, 54
2, 1, 30
3, 1, 55
4, 2, 20
5, 2, 45
i like to backup the tables "names" and "ages" but only the rows where group=1. Is there any mysqldump script where i can define the tables to backup and a where clause that must fit?
Thanks
Thanks Man i just tryed it but the result is not exactly what i need:
DROP TABLE IF EXISTS `names`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `names` (
...
) ENGINE=MyISAM AUTO_INCREMENT=619 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
mysql dump creates a drop table and a create table. It could not drop the table because there is much more data inside. It must create a delete statement based on the where clause like:
Delete from names where group = 1
without this i am not able to insert the backup a day later to restore and delete some faulty data. If someone inserts it without watching out he deletes the hole table.