Home >Database >Oracle >How to delete oracle constraints

How to delete oracle constraints

WBOY
WBOYOriginal
2022-01-26 11:08:459296browse

Method: 1. Use the "ALTER TABLE table name DROP CONSTRAINT constraint name;" statement to delete the primary key constraint; 2. Use the "Alter Table table Modify column type Null;" statement to delete the non-null constraint.

How to delete oracle constraints

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

How to delete oracle constraints

1. Delete primary key constraints:

Alter table 表名 drop 约束名

With named primary key:

Alter table one drop constraint pk_one;

No named primary key: Available Select * from user_constraints search The primary key name constraint_name in the table, and then use the found primary key name. For example: alter table student drop constraint SYS_C002715;

(When deleting component constraints, you must also delete the foreign key constraints that reference the primary key). For example:

alter table two drop constraint two_pk_id;

2. Delete non-empty constraints:

Syntax:

Alter Table 表 Modify 列 类型 Null;

For example:

Alter table one Modify name  null;

Recommended tutorial: "Oracle Video Tutorial"

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

Statement:
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