[英]Oracle Dynamically create script for Updating Partitioned table
I have a range partitioned Oracle table which I want to update using partition key. 我有一个要使用分区键更新的范围分区的Oracle表。
Is there a way to dynamically create update script which takes into account partition key as follows, WITHOUT having to manually maintain such script 有没有一种方法可以动态创建更新脚本,该脚本将分区键考虑如下,而无需手动维护该脚本
update table where date between 'a' and 'b'
update table where date between 'b' and 'c'.
I think it would not be necessary to specify the range in the where clause
to update individual partitions. 我认为没有必要在
where clause
指定范围来更新单个分区。 You may use the partition_extension_clause of update dynamically. 您可以动态使用partition_extension_clause更新 。
BEGIN
FOR r IN (
SELECT partition_name
FROM user_tab_partitions
WHERE table_name = 'YOUR_TABLE'
) LOOP
EXECUTE IMMEDIATE 'UPDATE YOUR_TABLE (' || r.partition_name || ') SET somecol = somevalue where someother_clause';
COMMIT; --if it's necessary
END LOOP;
END;
/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.