Learn the purpose and how to resolve the ORA-02270 error message in Oracle.
When you encounter an ORA-02270 error, the following error message will appear:
ORA-02270: no matching special or principal key for this column-list
You tried to reference a desk the usage of a unique or most important key, but the columns that you listed did no longer fit the major key, or a principal key does not exist for this table.
The option(s) to resolve this Oracle error are:
This error usually occurs when you strive to create a foreign key that references a desk that does not have a major key. To get to the bottom of this problem, create a predominant key on the referenced table. Then re-execute your command to create the overseas key.
For example, if you had tried to execute the following commands.
CREATE TABLE supplier ( supplier_id numeric(10) not null, supplier_name varchar2(50) not null, contact_name varchar2(50) ); CREATE TABLE products ( product_id numeric(10) not null, supplier_id numeric(10) not null, CONSTRAINT fk_supplier FOREIGN KEY (supplier_id) REFERENCES supplier (supplier_id) );
You would receive the following error message:
Since there is no predominant key on the supplier table, you can now not create a foreign key on the merchandise desk that references the supplier table.
You can right this error by including a major key to the dealer desk as follows and then re-execute the CREATE TABLE declaration for the merchandise table:
ALTER TABLE supplier ADD CONSTRAINT supplier_pk PRIMARY KEY (supplier_id);