This topic describes errors related to foreign key conflicts and the troubleshooting procedure.
Error: ORA-00600
Error message
ORA-00600: internal error code, arguments: -5317, Cannot add foreign key constraint
Example
When you create a foreign key constraint on the ty table, this error is returned, indicating that the referenced column is incorrect.
obclient> ALTER TABLE ty ADD CONSTRAINT ty FOREIGN KEY (t_id) REFERENCES tn(name);
ORA-00600: internal error code, arguments: -5317, Cannot add foreign key constraint
Troubleshooting procedure
View the schema of the
tntable, and determine whether the referenced column is the primary key or unique key. A column referenced by a foreign key must be the unique key or primary key column of the referenced table.obclient> DESC tn; +------------+---------------+------+-----+---------+-------+ | FIELD | TYPE | NULL | KEY | DEFAULT | EXTRA | +------------+---------------+------+-----+---------+-------+ | ID | NUMBER | NO | PRI | NULL | NULL | | NAME | VARCHAR2(128) | YES | NULL | NULL | NULL | | C_DISCOUNT | VARCHAR2(256) | YES | NULL | '0.99' | NULL | +------------+---------------+------+-----+---------+-------+ 3 rows in setSelect the primary key and create a FOREIGN KEY constraint again.
obclient> ALTER TABLE ty ADD CONSTRAINT ty FOREIGN KEY (t_id) REFERENCES tn(id); Query OK, 0 rows affected