When to use “ON UPDATE CASCADE”

It’s true that if your primary key is just a identity value auto incremented, you would have no real use for ON UPDATE CASCADE.

However, let’s say that your primary key is a 10 digit UPC bar code and because of expansion, you need to change it to a 13-digit UPC bar code. In that case, ON UPDATE CASCADE would allow you to change the primary key value and any tables that have foreign key references to the value will be changed accordingly.

In reference to #4, if you change the child ID to something that doesn’t exist in the parent table (and you have referential integrity), you should get a foreign key error.

Leave a Comment