[英]insert data from current month of partitioned table to a non partitioned table in oracle
I have a backup table with partitions called as backup_audit. 我有一个备份表,其分区名为backup_audit。 I need to insert the current month partition data into another non-partitioned table called as audit which has no data.
我需要将当前月份的分区数据插入另一个称为审计的未分区表中,该表没有数据。 How can we create a sql query to get the current month partition and load to the non-partitioned table?
我们如何创建一个SQL查询来获取当前月份的分区并加载到未分区的表中?
Here is what I've tried (without success): 这是我尝试过的方法(没有成功):
select partition_name
from dba_tab_partition
where partition_name in (
select high_value
from dba_tab_partition
where table_name='table_backup' and high_value in (
select to_char(sysdate, 'YYYYMM') from dual
)
)
You don't need to reference partitions to select the current months data. 您无需参考分区即可选择当前月份的数据。 Assuming that your backup_audit table is range partitioned by
audit_date
: 假设您的backup_audit表按
audit_date
范围划分:
insert
into audit(col1, col2, col3, ColN)
select col1, col2, col3, ColN
from backup_audit
where audit_date >= trunc(sysdate, 'MM')
and audit_date < last_day(trunc(sysdate)) + 1;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.