重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 958|回复: 0
打印 上一主题 下一主题

[认证考试] 创建引用分区报:ORA-14652: 不支持引用分区外键

[复制链接]
跳转到指定楼层
楼主
发表于 2023-8-30 18:51:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
CREATE TABLE new_order_items
( ORDER_ID NUMBER(12) ,
  LINE_ITEM_ID NUMBER(3) NOT NULL,
  PRODUCT_ID NUMBER NOT NULL,
  QUANTITY NUMBER NOT NULL,
  SALES_AMOUNT NUMBER NOT NULL,
  CONSTRAINT order_items_fk FOREIGN KEY(order_id) REFERENCES new_orders(order_id)
)
  PARTITION BY REFERENCE(order_items_fk);

ORA-14652: 不支持引用分区外键


[oracle@host01 ~]$ oerr ora 14652
14652, 00000, "reference partitioning foreign key is not supported"
// *Cause:  The specified partitioning foreign key was not supported
//          for reference-partitioned tables. All columns of the
//          partitioning foreign key must be constrained NOT NULL with
//          enabled, validated, and not deferrable constraints. Furthermore,
//          a virtual column cannot be part of the partitioning foreign key.
//* Action: Correct the statement to specify a supported

//          partitioning foreign key.

说明中提示了错误原因,如果使用Reference Partition,外键列是不允许为空的。标准外键定义并没有规定外键列必须为空,但是如果使用引用分区技术,就必须要求外键列不能为空。

这种约束其实也好理解。Reference Partition不需要明确指定分区键,但是实际上还是需分区键(或者称为分区因素)。如果没有外键值,也就失去了到主表分区的定位功能,Oracle必然不会允许创建。修改建表语句如下:

CREATE TABLE new_order_items
( ORDER_ID NUMBER(12)  not null,
  LINE_ITEM_ID NUMBER(3) NOT NULL
  PRODUCT_ID NUMBER NOT NULL,
  QUANTITY NUMBER NOT NULL,
  SALES_AMOUNT NUMBER NOT NULL,
  CONSTRAINT order_items_fk FOREIGN KEY(order_id) REFERENCES new_orders(order_id)
)

  PARTITION BY REFERENCE(order_items_fk);

即可。



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-5-17 17:04 , Processed in 0.085380 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表