Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how is cascading implemented in sql?

I have a tableA with primary key which acts for a foreign key for tableB.

How does sql delete rows from tableB if a row is deleted form tableA, assuming ON DELETE CASCADE is on.

Does SQL performs full-table scan for tableB?
And what if foreign column is indexed?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The DB will perform a full-table scan on B unless it doesn’t need to because the column is indexed. This is why you should always have your FKs indexed.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading