ORA-02270: no matching unique or primary key for this column-list : FOREIGN KEY « Table « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> CREATE TABLE employee (
  2  id                             number,
  3  name                           varchar(100),
  4  birth_date                     date,
  5  gender                         varchar2(30) );

Table created.

SQL>
SQL> CREATE TABLE employee_evaluation (
  2  id                             number,
  3  title                          varchar2(100),
  4  written_date                   date );

Table created.

SQL>
SQL>
SQL>
SQL>
SQL>
SQL> ALTER TABLE employee_evaluation ADD
  2  CONSTRAINT  employee_evaluation_fk1
  3  FOREIGN KEY        (id)
  4  REFERENCES  employee (id);
REFERENCES  employee (id)
                      *
ERROR at line 4:
ORA-02270: no matching unique or primary key for this column-list


SQL>
SQL>
SQL> drop table employee cascade constraint;

Table dropped.

SQL>
SQL> drop table employee_evaluation cascade constraint;

Table dropped.

SQL>








6.16.FOREIGN KEY
6.16.1.Adding a FOREIGN KEY Constraint
6.16.2.ON DELETE CASCADE clause with a FOREIGN KEY constraint
6.16.3.Use the ON DELETE SET NULL clause with a FOREIGN KEY constraint
6.16.4.ORA-02298: cannot validate (JAVA2S.PRODUCT_ORDER_FK_PRODUCT) - parent keys not found
6.16.5.A foreign key to reference itself
6.16.6.ORA-02270: no matching unique or primary key for this column-list
6.16.7.Add constraint foreign key references
6.16.8.Violate a foreign key
6.16.9.Disable foreign key
6.16.10.Many to many using a primary-key and foreign-key relationship