---
title: "Oracle 删除外键约束 禁用约束 启用约束"
author: "conkeyn"
date: "2012-04-23T12:39:04Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2012-04-23T12:38:54Z"
id: 1495328
url: "https://conkeyn.iteye.com/blog/1495328"
---

执行以下sql生成的语句即可

删除所有外键约束

```
select 'alter table '||table_name||' drop constraint '||constraint_name||';' from user_constraints where constraint_type='R'  
```

禁用所有外键约束

```
select 'alter table '||table_name||' disable constraint '||constraint_name||';' from user_constraints where constraint_type='R'  
```

启用所有外键约束

```
select 'alter table '||table_name||' enable constraint '||constraint_name||';' from user_constraints where constraint_type='R'
```

 

在