Home > Database > Oracle > How to invalidate foreign keys in oracle

How to invalidate foreign keys in oracle

WBOY
Release: 2022-05-25 15:45:18
Original
2371 people have browsed it

In Oracle, you can use the alter table statement with disable constraint to invalidate the foreign key. The syntax is "alter table table name disable constraint foreign key name;"; if the foreign key fails, the link between the two table data will be cancelled. one or more columns.

How to invalidate foreign keys in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How oracle invalidates foreign keys

Invalidate foreign keys:

alter table tableName disable constraint 外键名称;
Copy after login

We first create a foreign key named fk_supplier through the following code:

How to invalidate foreign keys in oracle

In this example, a primary key named supplier_pk is created on the supplier table. It contains only one field - supplier_id field. Then, we created a foreign key named fk_supplier on the products table. The supplier_id field of the products table refers to the supplier_id field of the suppliers table.

If you want to delete this foreign key, you can execute the following command:

How to invalidate foreign keys in oracle

Expand knowledge:

Enable foreign key Key recovery:

alter table tableName enable constraint 外键名称;
Copy after login

Delete foreign key:

alter table tableName drop constraint 外键名称;
Copy after login

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to invalidate foreign keys in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template