【问题标题】:Table partition is range or interval based表分区是基于范围或间隔的
【发布时间】:2014-07-02 06:55:34
【问题描述】:

我必须进行数据库分区测试,我现在在表中创建了间隔分区,如果我移动时钟进行测试,没有创建新分区?它仍然显示旧分区。知道如何解决这个问题吗? oracle数据库中如何判断表是范围分区还是区间分区?

使用以下代码进行分区删除后,我将间隔分区表作为范围分区。

SQL> create or replace procedure partition_delete(var in int) AS 2 v Date := SYSDATE; 3 i number; 4 occurance number; 5 l_drop_sql varchar2(2000); 6 BEGIN 7 execute immediate ' alter table "sch1"."AUDITS" set interval ()'; 8 execute immediate ' alter table "sch1"."ALERTAUDITS" set interval ()'; 9 -- select the tables that starts with either A or L having cfcc as table owner 10 for curs in ( select table_owner,table_name,partition_name,high_value from dba_tab_partitions where table_owner='owner' and REGEXP_LIKE (table_name,'^(A|L)')) LOOP 11 EXECUTE IMMEDIATE 'SELECT ' || curs.high_Value || ' FROM dual' INTO v; -- Conversion of high_value from long to date 12 select round(SYSDATE - v) into i from dual; -- finding the difference between current date and partition creation date 13 select count(*) into occurance from dba_tab_partitions where table_name=curs.table_name; -- Finding the no of existing partitions to the particular table 14 -- occurance>1 indicates table having only one partition is not getting deleted 15 if i > var and occurance > 1 then 16 dbms_output.put_line('The no of days are '||i); 17 dbms_output.put_line('The table name and partition name are '||curs.table_name||'and'||curs.partition_name); 18 l_drop_sql :='alter table "'||curs.table_owner||'"."'||curs.table_name||'" drop partition '||curs.partition_name||' update global indexes'; 19 dbms_output.put_line(l_drop_sql); 20 execute immediate l_drop_sql; 21 end if; 22 end LOOP; 23 execute immediate 'alter table "sch1"."AUDITS" set interval (NUMTOYMINTERVAL(1,''month''))'; 24 execute immediate 'alter table "CFCC"."ALERTAUDITS" set interval (NUMTOYMINTERVAL(1,''month''))'; 25 end; 26 /

程序已创建。

请帮帮我..

【问题讨论】:

  • 如何移动时钟进行测试?
  • 请给我们看一些代码,CREATE TABLES,SELECTs 你已经完成了等等......
  • 感谢您的代码。因此,程序运行,并打印出“ALTER TABLE ... DROP PARTITION...”,但分区仍然存在?
  • 嗨。执行后我得到其他表的区间字段为否,应该是对吗?

标签: oracle oracle11g


【解决方案1】:

对于区间分区,数据字典视图USER_TAB_PARTITIONS中的列INTERVAL设置为YES

SELECT table_name, partition_name, partition_position, INTERVAL, segment_created 
  FROM user_tab_partitions;

  TABLE_NAME  PARTITION_NAME PARTITION_POSITION INTERVAL SEGMENT_CREATED
  MYTABLE     PRE2014        1                  NO       NO
  MYTABLE     SYS_P385       2                  YES      YES
  MYTABLE     SYS_P401       3                  YES      YES
  MYTABLE     SYS_P441       4                  YES      YES

【讨论】:

    【解决方案2】:

    要查看表是否为区间分区,是否已创建基于区间的分区,您可以查看(DBA)(ALL)(USER)_PART_TABLES.INTERVAL。如果它不为 NULL,则此列包含在创建表或将表更改为间隔分区时指定的分区间隔。如果为 NULL,则表示该表不是间隔分区的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-14
      • 1970-01-01
      • 1970-01-01
      • 2011-10-11
      相关资源
      最近更新 更多