Help Others, Please Share. By admin. About Author. November 10, Leave a Reply Cancel reply Your email address will not be published. You should keep track of all data that's ever been in a database. If you are cascading 'on delete', then you have already decided you need to delete something. If you do decide to never delete anything, nothing will cascade. The benefit of having it though is that in your application you can be sure that when you look for a record with a foreign ID, you know that it will be there, and there wont be any orphan rows bloating your database should you decide to delete something.
The logic here is pretty faulty in places, and even more so in our new GDPR world. I do agree with the notion that if primary keys are changing, it might be a sign of something wrong though. Answer would be better served by defining 1,2,3 rather than relying on the question never being edited. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Helping communities build their own LTE networks. Podcast Making Agile work for data science. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Replace the constraint name in the script. The below example demonstrates this scenario. We will create a foreign key now with cascade as delete rule on States table which references to CountryID in parent table Countries.
But on Cities table, we have a foreign key constraint with no action for delete and the referenced value still exists in the table. Viewed 27k times. Improve this question.
Dimitar Spasovski Dimitar Spasovski 1, 6 6 gold badges 26 26 silver badges 38 38 bronze badges. If everything else fails read the instructions: docs.
Add a comment. Active Oldest Votes. Improve this answer. You don't need to drop it, you can disable it and turn it on. The best solution is to use deferred constraints, what will happen in this case- when executing the transaction you won't get errors- all the deferred constraints checking would happen on commit- and if you did all the required changes, it will behave the way you expect it to.
0コメント