如何删除以分区名称作为生成参数的 Oracle 分区
我必须删除超过 364 天的分区。 分区被命名为“log_20110101”,因此旧的分区 今天必须是
CONCAT('log_',TO_CHAR(SYSDATE -364,'YYYYMMDD'))
现在如果我尝试这样的语句,我会收到错误
ALTER TABLE LOG
DROP PARTITION CONCAT('log_',TO_CHAR(SYSDATE -364,'YYYYMMDD'));
-
Error report:
SQL Error: ORA-14048: a partition maintenance operation may not be combined with other operations
14048. 00000 - "a partition maintenance operation may not be combined with other operations"
*Cause: ALTER TABLE or ALTER INDEX statement attempted to combine
a partition maintenance operation (e.g. MOVE PARTITION) with some
other operation (e.g. ADD PARTITION or PCTFREE which is illegal
*Action: Ensure that a partition maintenance operation is the sole
operation specified in ALTER TABLE or ALTER INDEX statement;
operations other than those dealing with partitions,
default attributes of partitioned tables/indices or
specifying that a table be renamed (ALTER TABLE RENAME) may be
combined at will
i have to drop partitions which are older than 364 days.
Partitions are named as "log_20110101", so partitions which are older than
today will have to be
CONCAT('log_',TO_CHAR(SYSDATE -364,'YYYYMMDD'))
now if i try such a statement i get error
ALTER TABLE LOG
DROP PARTITION CONCAT('log_',TO_CHAR(SYSDATE -364,'YYYYMMDD'));
-
Error report:
SQL Error: ORA-14048: a partition maintenance operation may not be combined with other operations
14048. 00000 - "a partition maintenance operation may not be combined with other operations"
*Cause: ALTER TABLE or ALTER INDEX statement attempted to combine
a partition maintenance operation (e.g. MOVE PARTITION) with some
other operation (e.g. ADD PARTITION or PCTFREE which is illegal
*Action: Ensure that a partition maintenance operation is the sole
operation specified in ALTER TABLE or ALTER INDEX statement;
operations other than those dealing with partitions,
default attributes of partitioned tables/indices or
specifying that a table be renamed (ALTER TABLE RENAME) may be
combined at will
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
分区名称需要在发出 SQL 语句时固定,它不能是表达式。您应该能够执行类似的操作,迭代 USER_TAB_PARTITIONS 表,找出要删除的分区,并构建动态 SQL 来实际删除它们。
The partition name needs to be fixed at the time you issue the SQL statement, it cannot be an expression. You should be able to do something like this where you iterate over the
USER_TAB_PARTITIONS
table, figure out which partitions to drop, and construct the dynamic SQL to actually drop them.