无法删除外键(Oracle)
我正在尝试删除表的所有外键。首先,我使用 meta.getExportedKeys(null, null, table);
和 rs.getString("FK_NAME")
获取这些键的所有名称。
但是当我尝试使用以下命令删除此键时:
ALTER TABLE tablename DROP CONSTRAINT fkname
它仅适用于某些键。有时我会得到:
ORA-02443: Cannot drop constraint - nonexistent constraint
但是外键肯定是存在的。我做错了什么?
I'm trying to delete all foreign keys of a table. First I get all the names of those keys using meta.getExportedKeys(null, null, table);
and rs.getString("FK_NAME")
.
But when I try to delete this key using:
ALTER TABLE tablename DROP CONSTRAINT fkname
it only works for some keys. Sometimes I'm getting:
ORA-02443: Cannot drop constraint - nonexistent constraint
But the foreign key is definitely there. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你尝试
过吗?
您可能以区分大小写的方式创建了约束,在这种情况下,您需要在删除约束名称时将其放在双引号中。下面是 SQL*Plus 中的一个示例会话:
Have you tried
instead?
You might have created the constraint in a case-sensitive way, in which case, you'll need to put the constraint name in double quotes when you drop it. Here's an example session in SQL*Plus: