FOREIGN KEY ON DELETE RESTRICT Error - Oracle

前端 未结 1 1267
隐瞒了意图╮
隐瞒了意图╮ 2020-12-22 04:17

Lately I have been trying to add the following foreign key in the table, with the RESTRICT Clause in Oracle with the following command.:

ALTER TABLE 
Employe         


        
1条回答
  •  囚心锁ツ
    2020-12-22 04:47

    Oracle only supports ON DELETE SET NULL and ON DELETE CASCADE. You can achieve your requirement by simply doing the below query. No need to mention ON DELETE RESTRICT

    ALTER TABLE Employee_SalHead 
          ADD CONSTRAINT PAYROLL_SHEAD_FKEY FOREIGN KEY(SalHead_ID)
          REFERENCES SalHead(SalHead_ID);
    

    ON DELETE NO ACTION is Default. From Documentation

    The No Action (default) option specifies that referenced key values cannot be updated or deleted if the resulting data would violate a referential integrity constraint. For example, if a primary key value is referenced by a value in the foreign key, then the referenced primary key value cannot be deleted because of the dependent data.

    0 讨论(0)
提交回复
热议问题