oracle - Oracle 循环 - 声明
问题描述
我想使用 LOOP 遍历表中的所有分区来更改每个分区的一些数据。我开始喜欢:
BEGIN
FOR n in (here is the select statement which chooses the partition names)
LOOP
UPDATE table_name
PARTITION (n)
SET
here are columns to change with new values;
COMMIT;
END LOOP;
END;
我收到错误 ORA 02149 和 ORA 06512 分区不存在。它与某些声明有关吗?我应该怎么解决?
解决方案
您可以将数据字典视图一起execute immediate
用作user_tab_partitions
Begin
for c in ( select *
from user_tab_partitions p
where p.table_name = 'TABLE_NAME'
order by p.partition_position )
loop
execute immediate 'update '||c.table_name||' partition('||c.partition_name||')
set col1 = ''xYz'' ';
commit;
end loop;
End;
推荐阅读
- ios - 原生 ios webview 上的 Webrtc 支持
- hadoop - Hadoop 3.3 和 oozie 5.2.0
- scikit-learn - 我不明白在训练测试拆分和 MLP 回归器中更改随机状态之间的区别
- docker - 使用入口点执行脚本后将数据从容器复制到主机
- java - 使用 mTLS 和 WSS 时提取客户端证书信息
- javascript - 公开全局 API 方法来控制 vue 组件
- php - PHP 致命错误:未捕获的错误:调用未定义的方法 PDOStatement::rowCount()
- r - 做回归分析时如何评估随机森林的模型和预测?
- go - 有没有办法将 golang net/http 应用程序公开到我的本地网络?
- c# - 如何从 C# selenium 的下拉列表中找到值?