0

I have a large mySQL (InnoDB) database running on a production server, and I need to sync the staging DB with the production DB every once in a while.

One of the tables, let's called it generated_data, contains large amounts of data that change fairly often, therefore it doesn't need to be synced to the staging DB.

The problem is, another table contains an optional foreign key that points to generated_data, therefore I can't simply ignore the table. I need a way to set the foreign key to null when I perform the dump.

SnailCoil
  • 818
  • 1
  • 9
  • 23
  • http://stackoverflow.com/questions/2429655/can-you-automatically-create-a-mysqldump-file-that-doesnt-enforce-foreign-key-c – ogzd Jun 10 '13 at 20:10
  • and you can use `--ignore-table` to skip tables you want – ogzd Jun 10 '13 at 20:13
  • @ogzd The question you linked is asking about temporarily disabling the foreign key. The generated_data table won't be copied over, so the foreign keys need to be set to null, not temporarily ignored. – SnailCoil Jun 10 '13 at 20:21
  • 1
    you can write a small sql script (which sets to null) and run it after you took the dump – ogzd Jun 10 '13 at 20:29

0 Answers0