If there is an FK in child table that is not indexed then any updates to PK of the parent table locks entire child table, unless FK in child table is indexed.
My question is that if we want to prevent whole table lock then is the FK index has to be unique? Or It doesn't matter if the index is unique or non-unique?
The index doesn't have to be unique. It can be a regular or compound one.
The purpose of the index on a foreign key is to avoid full table locking while doing:
and is useful while doing joins by avoiding Full Table scans.
See http://www.dba-oracle.com/t_foreign_key_indexing.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With