Home > Database > Oracle > body text

How to delete oracle constraints

WBOY
Release: 2022-01-26 11:08:45
Original
9162 people have browsed it

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 约束名
Copy after login

With named primary key:

Alter table one drop constraint pk_one;
Copy after login

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;
Copy after login

2. Delete non-empty constraints:

Syntax:

Alter Table 表 Modify 列 类型 Null;
Copy after login

For example:

Alter table one Modify name  null;
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!