Non è questione di opinioni, in MySQL è obbligatorio l'indice su una chiave esternaOriginariamente inviato da whisher
Ciao.
Volevo conoscere la Vs. opinione riguardo
l'indicizzazione della foreign key.
E' buona regola indicizzare sempre una
foreign key ?
![]()
Riguardo alla sintassi:In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order. Starting with MySQL/InnoDB 4.1.2, such an index will be created on the referencing table automatically if it does not exist.
In the referenced table, there must be an index where the referenced columns are listed as the first columns in the same order.
codice:[CONSTRAINT symbol] FOREIGN KEY [id] (index_col_name, ...) REFERENCES tbl_name (index_col_name, ...) [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION}] [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION}]

Rispondi quotando