无法从头表中删除分区

发布于 2024-11-27 05:15:41 字数 546 浏览 2 评论 0原文

我们有一个包含主键的标头表和一个引用标头表(外键)的详细信息表。标题表和明细表均按月分区。这些表包含 5 年的数据,因此当新的月份到来时,第一个分区的数据将被删除,依此类推。因此始终只保留 5 年的数据。

我们面临的问题是,在从标头中删除分区时,我们收到以下错误:

ORA-02266: unique/primary keys in table referenced by enabled foreign keys
ORA-06512: at "SCH_TEST.DROP_PARTITION", line 51
ORA-06512: at line 16 (DBD ERROR: OCIStmtExecute)

我们已从详细表中删除了引用数据,但仍然出现上述错误。

解决此错误的一种方法是禁用约束,删除分区,然后启用约束。对于这个问题还有其他方法/解决方案吗?

数据库是Oracle 11G。

编辑1:如果我先删除分区中的数据然后删除它,我就可以从标头表中删除该分区。知道这是如何运作的吗?

We have a header table which has a primary key and a detail table which references the header table (Foreign key). Both the header and detail tables are monthly partitioned. These tables contain 5 years of data, so when a new month comes the data for the first partition is deleted and so on. So that always only 5 years of data is maintained.

The problem that we are facing is while dropping the partition from the header we are getting the following error:

ORA-02266: unique/primary keys in table referenced by enabled foreign keys
ORA-06512: at "SCH_TEST.DROP_PARTITION", line 51
ORA-06512: at line 16 (DBD ERROR: OCIStmtExecute)

We have deleted the referencing data from the detail table, still the above error is occuring.

One way for solving this error is to disable the constraint, drop the partition and then enable the constraint. Is there any other approach/solution for this issue.

Database is Oracle 11G.

Edit 1: I'm able to drop the partition from header table if i delete the data in the partition first and then drop it. Any idea how this works?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遥远的她 2024-12-04 05:15:41

Oracle 11g 为此引入了引用分区。您使用参考分区吗?如果没有,您需要更改分区方案。

Oracle 11g introduced partition by reference for this. Are you using reference partitioning? If not you need to change your partitioning scheme.

画中仙 2024-12-04 05:15:41

我选择“禁用引用约束,然后删除分区”方法,因为我没有找到解决此问题的任何其他解决方案。

在此发布此信息并接受它作为答案,以便它可以帮助搜索相同问题的其他人。

I chose "disable the reference constraint and then drop the partition" approach, as i did not find any other solution for this issue.

Posting this information here and accepting it as answer so that it may help others who search for the same issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文