简体   繁体   English

将当前月份的分区表中的数据插入到oracle中的非分区表中

[英]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.

相关问题 Oracle SQL - 使用 expdp/impdp 将数据从非分区(常规表)导入空分区表 - Oracle SQL - Import data from non-partitioned (regular table) into an empty partitioned table using expdp/impdp 非分区表上的分区索引 - partitioned index on a non partitioned table 如何使用merge语句将临时表中的数据插入oracle/sql中的分区表中 - How insert data from a temporary table into partitioned table in oracle/sql using merge statement Hive:如何将数据从分区表插入分区表? - Hive: How do I INSERT data FROM a PARTITIONED table INTO a PARTITIONED table? 将数据从一个分区表复制到另一个新的分区表 - copy data from one partitioned table to another new partitioned table Oracle SQL从每日分区的表中提取选定日期的数据 - Oracle SQL pull data for a selected date from a table that is daily partitioned BigQuery - 使用查询将数据插入分区表 - BigQuery - Insert data into a partitioned table using a query Databrick SQL - 将数据插入分区表 - Databrick SQL - Insert data to a partitioned table 从现有分区表创建分区表 - Create a partitioned table from existing partitioned table 分区表上未分区的索引 - Not partitioned index on partitioned table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM