Do I need to create indexes on foreign keys on Oracle?

后端 未结 7 541
粉色の甜心
粉色の甜心 2020-12-02 11:27

I have a table A and a table B. A has a foreign key to B on B\'s primary key, B_ID.

Fo

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 12:28

    UNIQUE, PRIMARY KEY, and FOREIGN KEY constraints generate indexes that enforce or "back" the constraint (and are sometimes called backing indexes). PRIMARY KEY constraints generate unique indexes. FOREIGN KEY constraints generate non-unique indexes. UNIQUE constraints generate unique indexes if all the columns are non-nullable, and they generate non-unique indexes if one or more columns are nullable. Therefore, if a column or set of columns has a UNIQUE, PRIMARY KEY, or FOREIGN KEY constraint on it, you do not need to create an index on those columns for performance.

提交回复
热议问题