原创

【oracle】ORA-14046 分区可以刚好分成两个新的分区

前言

运维的系统有个任务能自动执行分区脚本,自动进行表分区,但不是每次都灵,需要在年末去查下下一年的表分区是否创建,这不就查出问题了。

查询是否创建了表分区

查询是否创建了表分区的语句:


SELECT *
FROM DBA_TAB_PARTITIONS T
WHERE (T.TABLE_OWNER = 'OWNER_NAME' OR T.TABLE_OWNER = 'OWNER_NAME2')
  AND T.TABLE_NAME = 'TABLE_NAME'
  AND (T.PARTITION_NAME IN ('YEAR2024', 'YEAR_MAX') OR T.HIGH_VALUE_LENGTH=8);

执行表分区创建脚本

ALTER TABLE OWNER_NAME.TABLE_NAME SPLIT PARTITION YEAR_MAX  AT (TO_DATE('2024-12-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss')) 
INTO (PARTITION YEAR2024);

ALTER TABLE OWNER_NAME2.TABLE_NAME SPLIT PARTITION YEAR_MAX  AT (TO_DATE('2024-12-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss')) 
INTO (PARTITION YEAR2024);

报错:

ORA-14046: 分区可以刚好分成两个新的分区
14046. 00000 -  "a partition may be split into exactly two new partitions"
*Cause:    ALTER TABLE|INDEX SPLIT PARTITION did not contain
           descriptions of exactly two new partitions into which an existing
           table or index partition was to be split
*Action:   Ensure that the statement describes exactly two partition
           into which an existing partition is to be split

解决方式

 Ensure that the statement describes exactly two partition
           into which an existing partition is to be split

oracle 也告诉你了


ALTER TABLE OWNER_NAME.TABLE_NAME SPLIT PARTITION YEAR_MAX  AT (TO_DATE('2023-12-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss')) INTO (PARTITION YEAR2023, PARTITION YEAR_MAX)
ALTER TABLE OWNER_NAME2.TABLE_NAME SPLIT PARTITION YEAR_MAX  AT (TO_DATE('2023-12-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss')) INTO (PARTITION YEAR2023, PARTITION YEAR_MAX)

这么改就行了。

本文来自:【oracle】ORA-14046 分区可以刚好分成两个新的分区-小码农,转载请保留本条链接,感谢!

温馨提示:
本文最后更新于 2023年12月21日,已超过 73 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我
正文到此结束
本文目录