Sql 在oracle中将已分区表的当前月份的数据插入到未分区表中
我有一个带有分区的备份表,称为backup\u audit。我需要将当前月份的分区数据插入另一个称为audit的非分区表中,该表没有数据。我们如何创建一个sql查询来获取当前月份的分区并加载到非分区表中 以下是我尝试过但没有成功的方法:Sql 在oracle中将已分区表的当前月份的数据插入到未分区表中,sql,oracle,Sql,Oracle,我有一个带有分区的备份表,称为backup\u audit。我需要将当前月份的分区数据插入另一个称为audit的非分区表中,该表没有数据。我们如何创建一个sql查询来获取当前月份的分区并加载到非分区表中 以下是我尝试过但没有成功的方法: select partition_name from dba_tab_partition where partition_name in ( select high_value from dba_tab_partition where t
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
)
)
您不需要引用分区来选择当前月份的数据。假设备份\u审核表按审核日期进行范围分区:
我尝试了这一点,但没有从dba_tab_分区中选择分区名称,其中分区名称从dba_tab_分区中选择高值从dba_tab_分区中选择高值,表名称为table_backup,高值从select到charsysdate,'yyyyymm',不幸的是,高值是一个长数据类型。您需要使用pl/sql来提取要比较pita的时间戳
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;