删除外键约束 [英] Drop foreign-key constraint

查看:143
本文介绍了删除外键约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在创建过程中没有命名外键,如何删除外键

How to drop a foreign key if I have not named it during creation

create table abc(
id number(10),
foreign key (id) references tab(roll)
);

甚至

 alter table abc drop foreign key mn_ibfk_1;

不适用于我。

推荐答案

由于您没有指定约束名称,Oracle会为您生成一个c $ c> SYS_034849548 )。

As you did not specify a constraint name, Oracle generated one for you (something like SYS_034849548).

您需要找到约束名称才能删除它:

You need to find the constraint name in order to be able to drop it:

select constraint_name
from user_constraints
where table_name = 'ABC'
  and constraint_type = 'R'

将显示约束名称。然后你可以使用下面的方法删除约束:

will display the constraint name. Then you can drop the constraint using:

alter table abc drop constraint <constraint_name>;

(替换< constraint_name>

请注意语法是 alter table ... drop constraint 。没有 drop foreign key

Note that the syntax is alter table ... drop constraint. There is no drop foreign key.

这篇关于删除外键约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆