1

I want to turn cascade on by default. How can I do that in MySQL?

Preferably I'd like to edit my.cnf

TIMEX
  • 259,804
  • 351
  • 777
  • 1,080

2 Answers2

0

You can't turn it on by default.

You'll have to set it as a foreign key constraint on a key-by-key basis. See the documentation at http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html

Eljakim
  • 6,877
  • 2
  • 16
  • 16
0

The cascade on delete behavior is controlled when the individual foreign key constraints are created. There is no global setting for this.

Joe Stefanelli
  • 132,803
  • 19
  • 237
  • 235
  • Do you know how I can turn it on by default in SQLAlchemy? – TIMEX Nov 22 '11 at 21:52
  • @TIMEX: This question may help you: [sqlachemy: cascade delete](http://stackoverflow.com/questions/5033547/sqlachemy-cascade-delete) – Joe Stefanelli Nov 22 '11 at 21:54
  • not only can you not turn it on by default, it is a poor idea to do so. Cascade delete is very dangerous and should never be turned on to every table. Sometimes you want the database to stop you from delting data you need in a child table. Otherwise you can easily lose financial records your need to keep for instance. THis is a choice that shoud be made deliberately (and only after great thought as cascade delete can be a database performance killer) for every foreign key. – HLGEM Nov 22 '11 at 22:02